Python Data Mappings
How Python types map to server types
When sending data to the server, it does not serialize the type and will throw an error.
When reading AS_BYTES_PYTHON types from the server, it returns the raw bytes as a
bytearray. To deserialize this data, the application must use cPickle instead of relying on the client to do it automatically.
However, the functions
set_deserializer() allow for user-defined functions to handle serialization.
The serialized data is stored in the server with generic encoding (AS_BYTES_BLOB).
This type allows the storage of binary data readable by Aerospike Clients in other languages. The serialization config parameter of
aerospike.client() registers an instance-level pair of functions that handle serialization.
Aerospike is introducing a new boolean data type in server version 5.6.
In order to support cross client compatibility and rolling upgrades, Python client version
6.x comes with a new client config,
It configures how the client writes Python booleans and allows for opting into using the new boolean type.
It is important to consider how other clients connected to the Aerospike database write booleans in order to maintain cross client compatibility.
For example, if there is a client that reads and writes booleans as integers, then another Python client working with the same data should do the same thing.
send_bool_as can be set so the client writes Python booleans as integers or the Aerospike native boolean type.
All versions before
6.x wrote Python booleans as
The following table shows which Python types map directly to Aerospike server types.
It is possible to nest these datatypes. For example a list may contain a dictionary, or a dictionary may contain a list as a value.