aerospike-py

raw JSON →
0.10.5 verified Sat May 09 auth: no python

High-performance Aerospike Python client with sync and async APIs, built with PyO3 and Rust. Latest version 0.10.5; requires Python >=3.10. Active development with monthly releases.

pip install aerospike-py
error ModuleNotFoundError: No module named 'aerospike'
cause Old package name 'aerospike' vs new package 'aerospike-py'. Installing 'aerospike-py' gives module 'aerospike'.
fix
Run: pip install aerospike-py
error AttributeError: module 'aerospike' has no attribute 'client'
cause Using old import pattern 'import aerospike; client = aerospike.client(...)' which was removed.
fix
Use 'from aerospike import AerospikeClient; client = AerospikeClient(...)'.
error TypeError: AerospikeClient.__init__() got an unexpected keyword argument 'policies'
cause Old API where connection parameters were passed via 'policies' dict; now parameters are flat.
fix
Use 'seeds', 'username', 'password' directly: AerospikeClient(seeds=[...], username='...', password='...')
breaking The import path changed from 'aerospike.client' to 'from aerospike import AerospikeClient' in v0.9.0.
fix Use 'from aerospike import AerospikeClient' instead of 'import aerospike; client = aerospike.client(...)'.
gotcha The library requires Python >=3.10. Installing on older Python versions will fail.
fix Upgrade Python to 3.10 or later.
deprecated The old 'aerospike' package (C client) is not compatible. aerospike-py is a separate, Rust-based client.
fix Uninstall the old package: pip uninstall aerospike; then pip install aerospike-py.
gotcha Policy objects must be passed as keyword arguments, not positional. E.g., client.put(key, bins, policy=WritePolicy())
fix Always use keyword arguments for policies: client.put(key, bins, policy=my_policy).

Connect, write, and read a record with default settings.

import os
from aerospike import AerospikeClient, WritePolicy

client = AerospikeClient(
    seeds=[(os.environ.get('AEROSPIKE_HOST', 'localhost'), 3000)],
    username=os.environ.get('AEROSPIKE_USER', ''),
    password=os.environ.get('AEROSPIKE_PASSWORD', '')
)
policy = WritePolicy()
key = ('test', 'demo', 'hello')
bins = {'name': 'World'}
client.put(key, bins, policy=policy)
print(client.get(key))
client.close()