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 Common errors
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='...')
Warnings
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).
Imports
- AerospikeClient wrong
import aerospike client = aerospike.client(...)correctfrom aerospike import AerospikeClient - WritePolicy wrong
from aerospike.policy import WritePolicycorrectfrom aerospike import WritePolicy - client.put wrong
client.put(key, bins, policy=WritePolicy())correctfrom aerospike import AerospikeClient client = AerospikeClient(...) client.put(key, bins)
Quickstart
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()