sonnet-graph
Cypher graph database access for sonnet-server applications. It is the seam between the driver and a running process: pooling, lifecycle, readiness and in-graph metadata.
Version 0.3.1. It wraps cypher-graphdb>=0.5.0 and does not re-abstract it --
query building, result parsing, bulk loading, indexes and the differences
between the two backends all stay in the driver. The backends are Apache AGE
(on PostgreSQL) and Memgraph.
What it provides
GraphDBExtension-- pool lifecycle bound to the sonnet-server application lifecycle, with an optional mode for services where the graph is not required.- Pools -- named pools as the addressing scheme,
borrow_graphdb()as the entry point andget_current_graphdb()for the ambient connection. Managed mode adds lazy creation and idle reaping when the set of graphs is open-ended. - Readiness and status --
GraphdbStageinitialization and health checks on the sonnet-core readiness pipeline, plus pool snapshots for operations. - FastAPI dependencies --
get_graphdb()andget_graphdb_session()for router-level ambient connections. - Typed results -- per-pool model providers so query results come back as your own Pydantic classes.
- Graph metadata -- stores that keep a graph's schema, documentation and named queries as nodes inside the graph itself.
It defines no SQLModel tables and ships no migrations.
Install
uv add sonnet-graph
Depends on sonnet-core,
sonnet-server, cypher-graphdb, loguru and
jinja2. The backend drivers arrive with cypher-graphdb, so there is no
per-backend extra. The only extra is dev.
Usage
Register the extension once, then borrow a connection from anywhere in the process.
from sonnet_graph import GraphDBExtension, borrow_graphdb
registry = create_extension_registry(
DatabaseExtension(),
GraphDBExtension(),
)
with borrow_graphdb() as cdb:
result = cdb.execute("MATCH (n:Product) RETURN n LIMIT 10")
GraphDBExtension(optional=True) skips startup instead of raising when the
graph is unconfigured.
Configuration
The connection is configured through cypher-graphdb's own CGDB_
environment variables rather than being duplicated in consumer settings.
| Variable | Description |
|---|---|
CGDB_BACKEND |
Backend type: age or memgraph |
CGDB_CINFO |
Connection string / DSN |
CGDB_GRAPH |
Graph name |
CGDB_READ_ONLY |
Read-only mode (default: false) |
CGDB_CREATE_GRAPH_IF_NOT_EXISTS |
Auto-create the graph, AGE only (default: false) |
Documentation
- Usage --
docs/usage/index.md - Design --
docs/design/index.md - Workspace --
../../docs/README.md
License
Apache 2.0 -- see LICENSE.md.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sonnet_graph-0.3.2.tar.gz.
File metadata
- Download URL: sonnet_graph-0.3.2.tar.gz
- Upload date:
- Size: 31.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89befc15d768fb6e6beceb86da60cdfab934d6d8f2892cf7b868bdfad689c405
|
|
| MD5 |
1dd87fc9012eb039d09798858afc1714
|
|
| BLAKE2b-256 |
f2f6be0784db481c089ae5a624ec3d068dd7d684d1be913256b43b98d00f9cdd
|
Provenance
The following attestation bundles were made for sonnet_graph-0.3.2.tar.gz:
Publisher:
publish.yml on petrarca/sonnet-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sonnet_graph-0.3.2.tar.gz -
Subject digest:
89befc15d768fb6e6beceb86da60cdfab934d6d8f2892cf7b868bdfad689c405 - Sigstore transparency entry: 2567955774
- Sigstore integration time:
-
Permalink:
petrarca/sonnet-server@8fb257794749ed1922438cbfb5ef82eeb548d71d -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/petrarca
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8fb257794749ed1922438cbfb5ef82eeb548d71d -
Trigger Event:
push
-
Statement type:
File details
Details for the file sonnet_graph-0.3.2-py3-none-any.whl.
File metadata
- Download URL: sonnet_graph-0.3.2-py3-none-any.whl
- Upload date:
- Size: 38.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56e63e4057f1b94df7a4f0fbf88d903d203b3e6a8fe2345b57acad6ae7237b1b
|
|
| MD5 |
f621aca1512863716ea93f72aef61cbf
|
|
| BLAKE2b-256 |
f1aecb04d5c4148b9e03f914d8ad719c32b06201c34a30dc467f3fa43a050d77
|
Provenance
The following attestation bundles were made for sonnet_graph-0.3.2-py3-none-any.whl:
Publisher:
publish.yml on petrarca/sonnet-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sonnet_graph-0.3.2-py3-none-any.whl -
Subject digest:
56e63e4057f1b94df7a4f0fbf88d903d203b3e6a8fe2345b57acad6ae7237b1b - Sigstore transparency entry: 2567955921
- Sigstore integration time:
-
Permalink:
petrarca/sonnet-server@8fb257794749ed1922438cbfb5ef82eeb548d71d -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/petrarca
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8fb257794749ed1922438cbfb5ef82eeb548d71d -
Trigger Event:
push
-
Statement type: