Python Client SDK
Installing Python client SDK
pip install oxia
PyDoc documentation is available at https://oxia-db.github.io/oxia-client-python/latest
Client API
Initializing the client
To use the Oxia client, you need to create a client instance. Once created, a client instance will be valid until it’s explicitly closed, and it can be used from different threads.
import oxia
client = oxia.Client("localhost:6648")
When creating the client is possible to pass several options, such as:
client = oxia.Client("localhost:6648",
namespace="my-namespace",
client_identifier="my-client-identity",
)
For the full list of options, see the Client constructor docs .
Writing records
# Write a record to Oxia with the specified key and value, and with the expectation
# that the record does not already exist.
key, version1 = client.put("my-key", "value-1",
expected_version_id=oxia.EXPECTED_RECORD_DOES_NOT_EXIST)
# Write a record with the expectation that it has not changed since the previous write.
# If there was any change, the operation will fail
key, version2 = client.put("my-key", "value-2",
expected_version_id=version1.version_id())
All the options for the put operation are available in the put() method docs .
Reading records
Reading the value of a record
key, value, version = client.get("my-key")
All the options for the get operation are available in the get() method docs .
Last updated on