ZydecoDB Python driver
Official Python client for ZydecoDB. Pure standard library, no runtime dependencies.
Wire reference: this client is the hand-maintained reference codec. Go and
TypeScript track the same bytes via ../conformance/vectors.json
(CI job wire-conformance).
Install
pip install zydecodb
Requires Python 3.9+. (Working from a checkout of this repo:
pip install -e clients/python.)
Quick start
from zydecodb import Client
# Plain TCP (localhost). For TLS: Client(..., api_key="YOUR_KEY", tls=True)
with Client("127.0.0.1", 9470, api_key="YOUR_KEY") as db:
users = db.collection("users")
users.create_index(["email"], unique=True)
uid = users.insert_one({"email": "ada@example.com", "name": "Ada", "age": 30})
for u in users.find({"age": {"$gte": 18}}, sort=[("age", True)]):
print(u["name"], u["age"])
users.update_one({"_id": uid}, {"$inc": {"age": 1}})
print(users.count_documents())
What you get
- Connection pooling.
Clientowns a thread-safe pool (pool_size, default 8) and is safe to share across threads. - Automatic retries with backoff. Transient transport failures and server
EngineBusyresponses are retried (full-jitter exponential backoff) for operations that are safe to repeat. Operator updates and deletes are never retried automatically. - Keepalive. Idle pooled connections are validated with a
Pingon checkout and transparently replaced if dead. - Typed error taxonomy. Non-OK responses raise a specific subclass:
ConflictError(unique-index violation),AuthError,ServerBusyError,InvalidRequestError, or the baseServerError— each carrying the wirestatusbyte. Transport problems raiseConnectionError. CollectionAPI.insert_one/many,find/find_one,update_one/many,delete_one/many,count_documents,distinct,create_index, with$-operators, sort, projection, and skip/limit. Pagination is repeatable-read across pages.- Raw KV with TTL. Side-channel
put(withexpires_at),get, anddeletemethods onClientfor session data that needs a time-to-live. - TLS. Pass
tls=Truefor system CA defaults, or anssl.SSLContextfor custom roots / verification.
Optimistic concurrency
got = users.get_with_revision(uid)
doc, rev = got
doc["age"] += 1
try:
users.replace_one_if_match(uid, doc, if_match=rev)
except ConflictError:
pass # re-read and retry, or merge
Also: find_with_revision, update_by_id_if_match. Revisions are opaque
integers. Stale/missing documents raise ConflictError. Against an older
server these methods fail with a protocol error instead of silently becoming
unconditional writes.
Bounded transactions
with db.transaction() as tx:
tx.put(b"session", b"active")
tx.put_document("users", "u1", {"n": 1})
Pins one connection for the duration; no automatic retries. Collections must
already exist. Filter queries/updates and DDL are rejected inside a transaction.
Commit transport failure raises UnknownCommitError — reconcile by re-reading
keys. Older servers reject Begin with a protocol error.
Durability
Writes are durable (fsync-on-commit) by default. For latency-sensitive,
loss-tolerant writes, pass relaxed=True to acknowledge before the fsync.
It is available on every write: insert_one, replace_one, update_one,
update_many, delete_one, and delete_many.
users.insert_one(doc, relaxed=True)
users.update_one({"_id": "ada"}, {"$inc": {"hits": 1}}, relaxed=True)
users.delete_many({"stale": True}, relaxed=True)
Filtered positional $set (exactly one array match) uses the same update APIs
with a path like items.$[skuId=ABC].qty — no new client methods.
Directional indexes: pass ("field", False) tuples in create_index for DESC
(e.g. [("ownerId", True), ("updatedAt", False)]).
Running the tests
Unit + wire conformance (no server):
cd clients/python
pip install -e ".[dev]"
pytest tests/test_protocol.py tests/test_conformance.py
Integration tests run against a live server selected by environment variables (skipped automatically if it is unreachable):
ZYDECODB_TEST_HOST=127.0.0.1 ZYDECODB_TEST_PORT=9470 pytest
Release files for zydecodb 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| zydecodb-1.1.0.tar.gz | 21.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zydecodb-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.5 kB
Release files / zydecodb-1.1.0.tar.gz
| Download URL | zydecodb-1.1.0.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab4699d71229faa4e6f9aaba9cd6da34a24c73f1d32e0fbaf5669096ae763ecc
|
|
BLAKE2b-256 checksum How to use checksums |
124861c4a3e43b80052624c2622d312c7061b2024ebbb27b139192ab0379ca84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / zydecodb-1.1.0-py3-none-any.whl
| Download URL | zydecodb-1.1.0-py3-none-any.whl |
|---|---|
| Size | 21.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e789b778628143cdafed577551e2c0a50adfb55b7c17d64a24d37d2109529e53
|
|
BLAKE2b-256 checksum How to use checksums |
562713845381d571c4f3f44fc96e3400366bc601153c5c1cb3ab06e2b04432da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency log