Skip to main content

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, or None.
  • 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 the ResultSummary (counters.nodes_created and 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.16.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nomosdb 0.16.0
File Size Uploaded
nomosdb-0.16.0.tar.gz 47.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nomosdb 0.16.0
File Interpreter ABI Platform
nomosdb-0.16.0-py3-none-any.whl Python 3 none any Details

Total release size: 98.9 kB

Release files / nomosdb-0.16.0.tar.gz

Download URL nomosdb-0.16.0.tar.gz
Size 47.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1ccd4aa700bb28ceede0f495ac4f8665abb3306e53c201fc2c7fd28f6a65100f
BLAKE2b-256 checksum
How to use checksums
d5feb79afdbf843e378deead75739b0802fb1fb14903b2d8eaae6bc40a7d5dd6
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 10, 2026.

Transparency log

Release files / nomosdb-0.16.0-py3-none-any.whl

Download URL nomosdb-0.16.0-py3-none-any.whl
Size 51.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64e0b189348330913b9663090e8602b9ce412759cb19ff0d0916c0b216bc1f27
BLAKE2b-256 checksum
How to use checksums
00d4db70af9940ad7b4129d859e184617041a9b223d552ed1d92f1a49c820416
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 10, 2026.

Transparency log

Release history Release notifications | RSS feed

0.25.0

2 release files

0.24.0

2 release files

0.23.0

2 release files

0.22.0

2 release files

0.21.0

2 release files

0.20.0

2 release files

0.19.0

2 release files

0.18.0

2 release files

0.17.0

2 release files

This release

0.16.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page