nomosdb — the Python driver for NomosDB
The official Python driver for NomosDB, a graph database you query in Cypher (NomosDB calls its dialect DQL).
- Native Bolt 5.0–5.4, the protocol the Neo4j drivers use.
- Transactions that commit or roll back as a whole.
- Managed transactions that are retried on conflicts and leader changes.
- Cluster routing with causal consistency.
- asyncio.
- Pure Python, no dependencies, Python 3.9+.
pip install nomosdb
Quick start
import nomosdb
driver = nomosdb.driver("bolt://localhost:7687", auth=("nomosdb", "secret"))
with driver.session() as session:
# one statement, committed on its own; records stream in batches
for record in session.run("MATCH (p:Person) WHERE p.age > $min RETURN p.name AS name", min=30):
print(record["name"])
# a managed transaction: on a transient failure the whole function runs again
def transfer(tx, a, b, amount):
tx.run("MATCH (x:Account {id: $a}) SET x.balance = x.balance - $n", a=a, n=amount)
tx.run("MATCH (x:Account {id: $b}) SET x.balance = x.balance + $n", b=b, n=amount)
session.execute_write(transfer, 1, 2, 10)
# an explicit transaction
with session.begin_transaction() as tx:
tx.run("CREATE (:Person {name: $name})", name="Ann")
tx.commit() # leaving the block without commit() rolls back
# bulk loading: one retried transaction per batch, the batch as $rows
session.write_batch("UNWIND $rows AS r CREATE (:Person {name: r.name})",
({"name": f"p{i}"} for i in range(100_000)), batch_size=5000)
driver.close()
asyncio
import asyncio
import nomosdb
async def main():
async with nomosdb.async_driver("bolt://localhost:7687", auth=("nomosdb", "secret")) as driver:
async with driver.session() as session:
result = await session.run("MATCH (p:Person) RETURN p.name AS name")
async for record in result:
print(record["name"])
asyncio.run(main())
Every method of the blocking API exists in the async one under the same name. The async version adds await, async with and async for.
URIs
| URI | Meaning |
|---|---|
bolt://host:7687 |
One server. |
bolt+s://host:7687 |
One server over TLS, with the certificate verified (system CAs, or trusted_certificates="ca.pem"). |
bolt+ssc://host:7687 |
One server over TLS, accepting a self-signed certificate. |
nomosdb://host:7687 |
A cluster. neo4j:// is also accepted. |
nomosdb+s://, nomosdb+ssc:// |
A cluster over TLS. |
With a cluster URI, the driver asks any member for the routing table. Writes go to the leader and reads are spread over the members. Each session passes its bookmark to the next transaction, so a read sees the session's earlier writes on whichever member serves it.
Results
session.run() and tx.run() return a Result. You can iterate it, or call one of these methods:
single(): the one record, orNone.data(): a list of dicts.value(): the first column.to_list(): all records.peek(): the next record without consuming it.consume(): skips the remaining records and returns theResultSummary(counters.nodes_createdand the other counters,query_type,bookmark).
A Record reads by name or by position: record["name"], record[0], record.data().
Nodes, relationships and paths come back as nomosdb.graph.Node, Relationship and Path. You read their properties like a dict, and they also have labels, type, start_node, end_node and element_id.
Errors
| Exception | When |
|---|---|
ClientError |
The statement is wrong: syntax, a missing parameter, a constraint. code holds the server's Neo.ClientError.* code. |
TransientError |
A write conflict or a lock timeout. Managed transactions retry it. |
AuthError |
Wrong credentials, or a role that is too low. |
ServiceUnavailable, SessionExpired |
No server is reachable, or a connection broke. Managed transactions retry these. |
TransactionCommitUnknown |
The connection broke after COMMIT was sent, so the transaction may have committed. It is never retried automatically. |
Driver options
nomosdb.driver(uri, auth, **options) accepts these options:
| Option | Default | Meaning |
|---|---|---|
max_connection_pool_size |
100 | Most connections kept per server. |
connection_timeout |
30 s | Limit on TCP connect, TLS and Bolt handshake. |
connection_acquisition_timeout |
60 s | How long to wait for a free pooled connection. |
max_transaction_retry_time |
30 s | How long managed transactions keep retrying. |
fetch_size |
1000 | Records per batch. |
trusted_certificates |
system CAs | CA file for +s URIs. |
user_agent |
nomosdb-python/<version> |
Sent to the server. |
The earlier client
The 0.1 API still works:
NomosDB(uri).query()returns rows as dicts.- The ORM (
@node_class,Model.objects.filter(...)) works as before.
With a bolt:// URI these use the driver above, so db.session().begin_transaction() is a real transaction.
With http://, each statement commits on its own, and begin_transaction() raises TransactionError. It no longer returns an object that only looked like a transaction.
Development
cd nomosdb-python
python tools/unasync.py # after editing nomosdb/_async/: regenerates nomosdb/_sync/
NOMOSDB_SERVER=../build/tools/nomosdb-server NOMOSDB_CERTS=../build/tools/nomosdb-certs python -m pytest tests
The tests start real nomosdb-server processes: a single server, a TLS server and a three-member cluster.
License: Apache-2.0.
Metadata
Release files for nomosdb 0.22.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 | |
|---|---|---|---|
| nomosdb-0.22.0.tar.gz | 52.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nomosdb-0.22.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 107.1 kB
Release files / nomosdb-0.22.0.tar.gz
| Download URL | nomosdb-0.22.0.tar.gz |
|---|---|
| Size | 52.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b6e624b0d4a1fd03a7784a0b73c35251fd0b3bd8491fe5c50fb965450acbff4
|
|
BLAKE2b-256 checksum How to use checksums |
78247f3f255b7eef9ee53f8a4d3488b715f982854dd6df96a0bca6a27a9b90e0
|
| 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 12, 2026.
Transparency logRelease files / nomosdb-0.22.0-py3-none-any.whl
| Download URL | nomosdb-0.22.0-py3-none-any.whl |
|---|---|
| Size | 54.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
36baa3c503e8a51e5b555b3d0653b74fbf521c57fdc37413dd2b55b439763b8b
|
|
BLAKE2b-256 checksum How to use checksums |
8559602b2f145ae300bd8dda05cd73ebb6c86528faad75f3d8ef6fab3e31c86b
|
| 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 12, 2026.
Transparency log