zebridge (Python)
A ZeBridge client for Python: a local replica that follows PostgreSQL through the bridge, and writes back through it. Pure Python over libzb's C ABI — no ctypes in your code. Which library for which host: DISTRIBUTION.md.
pip install zebridge
The wheels carry libzb for Linux (x86_64, aarch64; glibc 2.35+) and macOS (Apple silicon, Intel; 13+). Python 3.10 or later.
Use
from zebridge import ZeBridge
with ZeBridge(bridge_url="https://zb.example.com", invite=code, tables=["orders"],
on_change=lambda r: print("changed:", r.get("changed_tables"))) as zb:
rows = zb.query("SELECT * FROM orders WHERE status = ?", "open") # list of dicts
zb.mutate("orders", "UPDATE", {"id": 7}, {"status": "done"})
- The options are the ones every ZeBridge client reads (CLIENTS.md), in camelCase or
snake_case (
bridge_urlisbridgeUrl). A dict works too:ZeBridge({"bridgeUrl": …}). - Enrollment. The first run redeems
inviteat the bridge and keeps the identity next to the replica (identity_path, default<db_path>.identity, mode 0600). Later runs need neither the invite nor a NATS URL, and the JWT renews itself before it expires. - The thread. libzb drives a client from one thread;
ZeBridgeowns it. Any thread may call it. An idle client polls everypoll_ms(250 ms); while calls keep coming, the thread serves each one at once and still polls everypoll_ms, so a writer in a loop runs at its own pace (measured: 1,700 writes/s, all settled).on_changehears every poll that applied rows, settled writes or brought requests — on the worker thread (calling back intozbfrom it is fine). - Errors raise
ZeBridgeErrorwith libzb's words.on_errorhears the loop's. - Revocation. Once revoked,
zb.revokedis true and the loop stops;wipe()removes the rows. - Asking a service.
request(subject, payload), andingestto keep the answer's rows in an on-demand table.
A service
A service answers questions that clients ask with request("query.<tenant>.<name>", …).
It needs a responder's creds (bridge --mint-responder). Write one handler per question:
from zebridge import ZeBridge
with ZeBridge(nats_url="tls://nats.example.com:4222", creds_path="airports.creds",
db_path="airports.sqlite3", tables=["airports"]) as zb:
def by_code(q: dict, tenant: str):
return zb.query("SELECT * FROM airports WHERE code = ?", q["code"])
zb.serve(["_default"], {"airport_by_code": by_code}, queue="airports")
zb.wait() # until SIGINT or SIGTERM
- A handler gets the asker's payload and the tenant from the subject (never from the payload), and returns any JSON.
- A handler that raises answers
{"error": "<Type>: <message>"}, so the asker never waits out a timeout. - Handlers run on the client's thread, between two polls. Instances with the same
queueshare the questions. - An answer too large for one message goes through the tenant's object store; the asking library fetches it.
Example: examples/10-airports/airport_service.py.
The library
ZB_LIB names libzb's shared library; else a copy bundled in the package
(zebridge/lib/), else the repository's own build (cd libzb && zig build -Doptimize=ReleaseFast), else the system's: on Debian and Ubuntu, sudo apt install ./libzb_<version>_<arch>.deb puts it where the loader finds it. ZB_ABI pins the C ABI this package speaks; libzb/python/abi_check.py
checks it with the other bindings.
Metadata
Release files for zebridge 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| zebridge-0.2.5-py3-none-manylinux_2_35_x86_64.whl | Python 3 | none | Linux glibc 2.35+ x86-64 | Details |
| zebridge-0.2.5-py3-none-manylinux_2_35_aarch64.whl | Python 3 | none | Linux glibc 2.35+ ARM64 | Details |
| zebridge-0.2.5-py3-none-macosx_13_0_x86_64.whl | Python 3 | none | macOS 13.0+ x86-64 | Details |
| zebridge-0.2.5-py3-none-macosx_13_0_arm64.whl | Python 3 | none | macOS 13.0+ ARM64 | Details |
Total release size: 20.6 MB
Release files / zebridge-0.2.5-py3-none-manylinux_2_35_x86_64.whl
| Download URL | zebridge-0.2.5-py3-none-manylinux_2_35_x86_64.whl |
|---|---|
| Size | 8.3 MB |
| Tags | Linux glibc 2.35+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
65359854499047706a05efc77f776d5084b56485b5229eb5150ccdff072678e9
|
|
BLAKE2b-256 checksum How to use checksums |
0c5d3249c2f7093cbc86f2302483d8e1ab50e4210d14542c93d2929516f5f4c5
|
| 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 Oct 16, 2026.
Transparency logRelease files / zebridge-0.2.5-py3-none-manylinux_2_35_aarch64.whl
| Download URL | zebridge-0.2.5-py3-none-manylinux_2_35_aarch64.whl |
|---|---|
| Size | 7.9 MB |
| Tags | Linux glibc 2.35+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
95d39f33abbe2be78958ae08eee222b57b2d77a90b680b548657e02b45086e2a
|
|
BLAKE2b-256 checksum How to use checksums |
ce4883eba2bea752f67def96e4d7f7b35ba759facd8c971aab1da1ef77f05ffb
|
| 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 Oct 16, 2026.
Transparency logRelease files / zebridge-0.2.5-py3-none-macosx_13_0_x86_64.whl
| Download URL | zebridge-0.2.5-py3-none-macosx_13_0_x86_64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | Python 3 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
6a5d67a4cd4c4b10c02b246cd2cf701ccc9028ec6590ba4a174af0e3bfa9f50a
|
|
BLAKE2b-256 checksum How to use checksums |
5982d818909cfd0a5a7d5400f89fe8f6aac65d507246d40f1e12a717ff25562c
|
| 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 Oct 16, 2026.
Transparency logRelease files / zebridge-0.2.5-py3-none-macosx_13_0_arm64.whl
| Download URL | zebridge-0.2.5-py3-none-macosx_13_0_arm64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | Python 3 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
533fd54dbad01259b7a94eb6f52b8fbc5c2e963c7e6f723a1558cca8cba54a29
|
|
BLAKE2b-256 checksum How to use checksums |
3aee057bef5a46214be9e0a1d83e3b5fdc907a6f1f9de8b542bd50a95610e2a9
|
| 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 Oct 16, 2026.
Transparency log