GestaltDB
GestaltDB is a pure Python graph database toolkit for attributed graphs. It stores nodes, edges, labels, typed adjacency records, and property indexes on embedded key-value backends.
Documentation: https://mylonasc.github.io/gestaltdb/
Install From PyPI
With pip:
python -m pip install gestaltdb
With uv:
uv add gestaltdb
Install columnar ingestion dependencies:
python -m pip install "gestaltdb[arrow,polars]"
Install only the backend and serializer you need. Extras are additive, so any backend can be paired with any serializer without combination-specific extras:
python -m pip install "gestaltdb[leveldb,msgpack]"
python -m pip install "gestaltdb[lmdb,protobuf]"
python -m pip install "gestaltdb[rocksdb]"
Pickle and JSON serialization are built in. A base install intentionally does not install an embedded KV backend. Install all backends and serializers with:
python -m pip install "gestaltdb[backends,serializers]"
GraphDB.create() keeps RocksDB/PyRex as its compatibility default, so a base
install must pass an installed backend explicitly and never silently falls back.
Install every optional integration, including ingestion and benchmark clients:
python -m pip install "gestaltdb[all]"
Optional extras include lmdb, leveldb, rocksdb, backends, msgpack, protobuf, serializers, arrow, polars, fast-ingest, bloom, docs, dev, and all.
Dependency Vulnerability Scan
Run the Docker-based Trivy scan for the cartesian product of KV backends
(leveldb, lmdb, rocksdb) and serializers (builtin JSON/Pickle as json,
plus msgpack and protobuf extras) — 9 locked runtime sets:
./scripts/scan_backend_vulnerabilities.sh
The script exports locked production dependencies in a uv container and writes table and JSON reports to security-reports/ as <backend>-<serializer>.json/txt (for example leveldb-msgpack.json). Development and documentation dependencies are excluded. Set FAIL_ON_SEVERITY=HIGH,CRITICAL to return a nonzero status when policy-level findings are present.
Basic Example
from tempfile import TemporaryDirectory
from gestaltdb.graphdb import Edge, GraphDB, Node
from gestaltdb.kvstores import LevelDBStore
from gestaltdb.serializers import PickleSerializer
with TemporaryDirectory() as tmpdir:
graph = GraphDB(LevelDBStore(path=f"{tmpdir}/graph"), PickleSerializer())
graph.put_node(Node(node_id="alice", labels=["Person"], properties={"name": "Alice"}))
graph.put_node(Node(node_id="bob", labels=["Person"], properties={"name": "Bob"}))
graph.put_edge(Edge(
edge_id="alice-knows-bob",
source="alice",
target="bob",
properties={"type": "knows", "since": 2024},
))
result = graph.query('MATCH (a:Person {name: "Alice"}) MATCH (a)-[:knows]->(b) RETURN a.id, b.name')
print(result.records)
graph.close()
Arrow Ingestion Example
This example ingests entity columns from PyArrow arrays. JSONSerializer lets GestaltDB build node and edge payloads from structured columns.
from tempfile import TemporaryDirectory
import pyarrow as pa
from gestaltdb.graphdb import GraphDB
from gestaltdb.kvstores import LevelDBStore
from gestaltdb.serializers import JSONSerializer
from gestaltdb import IndexMaintenanceMode
with TemporaryDirectory() as tmpdir:
graph = GraphDB(LevelDBStore(path=f"{tmpdir}/graph"), JSONSerializer())
graph.create_node_property_index("name")
result = graph.ingest_arrow(
pa.array(["alice", "bob", "carol"]),
pa.array(["alice-knows-bob", "bob-knows-carol"]),
pa.array(["alice", "bob"]),
pa.array(["bob", "carol"]),
pa.array(["knows", "knows"]),
labels=pa.array([["Person"], ["Person"], ["Person"]]),
node_properties={"name": pa.array(["Alice", "Bob", "Carol"]), "age": pa.array([34, 36, 29])},
edge_properties={"since": pa.array([2024, 2025])},
index_mode=IndexMaintenanceMode.DEFER_REBUILD,
)
print(result) # {'nodes': 3, 'edges': 2, 'rebuilt_indexes': ..., 'stale_indexes': ()}
result = graph.query('MATCH (a:Person {name: "Alice"}) MATCH (a)-[:knows]->(b) RETURN a.id, b.name')
print(result.records)
graph.close()
Polars Ingestion Example
This example ingests the same graph from Polars DataFrames. Property columns are converted into node and edge payloads during ingestion.
from tempfile import TemporaryDirectory
import polars as pl
from gestaltdb.graphdb import GraphDB
from gestaltdb.kvstores import LevelDBStore
from gestaltdb.serializers import JSONSerializer
from gestaltdb import IndexMaintenanceMode
nodes = pl.DataFrame({
"node_id": ["alice", "bob", "carol"],
"labels": [["Person"], ["Person"], ["Person"]],
"name": ["Alice", "Bob", "Carol"],
"age": [34, 36, 29],
})
edges = pl.DataFrame({
"edge_id": ["alice-knows-bob", "bob-knows-carol"],
"source": ["alice", "bob"],
"target": ["bob", "carol"],
"edge_type": ["knows", "knows"],
"since": [2024, 2025],
})
with TemporaryDirectory() as tmpdir:
graph = GraphDB(LevelDBStore(path=f"{tmpdir}/graph"), JSONSerializer())
graph.create_node_property_index("name")
graph.ingest_polars(
nodes,
edges,
node_property_columns=["name", "age"],
edge_property_columns=["since"],
index_mode=IndexMaintenanceMode.DEFER_REBUILD,
)
result = graph.query('MATCH (a:Person) MATCH (a)-[:knows]->(b) RETURN a.name, b.name ORDER BY a.name')
print(result.records)
graph.close()
Install From A Checkout
From a local checkout:
uv sync
Install into another project:
uv add /path/to/gestaltdb
With pip:
python -m pip install /path/to/gestaltdb
Backend and Ingestion Recommendations
For the current library:
- Use
LevelDBStorefor small local graphs, examples, and straightforward embedded use. - Use
PyRexStore/RocksDB for large append-only loads and Arrow/Polars columnar ingestion. - Use
LMDBStorewhen LMDB's storage model is desirable and you can sizemap_sizeahead of loading. - Use
JSONSerializerwithGraphDB.ingest_polarsorGraphDB.ingest_arrowwhen input data is already tabular and JSON-compatible. - Use pre-serialized
node_valueandedge_valuecolumns when upstream data already has serializer-compatible payload bytes. - Keep
IndexMaintenanceMode.MAINTAINfor incremental writes that need indexes ready immediately. - Use
IndexMaintenanceMode.DEFERorDEFER_REBUILDfor bulk loads when you want to move secondary-index work out of the write path.
Measured locally on 100k nodes and 500k edges, RocksDB native columnar ingestion was 1.16x faster end-to-end than LevelDB on the same Python JSON payload path, and Polars JSON payload construction was 1.86x faster than Python JSON serialization. Deferred indexing made the write phase 8.72x faster, but immediate full rebuild made total ingest-plus-rebuild 17.2% slower for that subset. Treat these as workload-specific guidance and benchmark your graph shape, serializer, and indexes.
Features
- Attributed
NodeandEdgeobjects with stable IDs. - Native node labels and typed edge traversal through
edge.properties["type"]. - LMDB, LevelDB, and RocksDB/PyRex storage backends.
- Pickle, JSON, MessagePack, and Protobuf serializers.
- Label, relationship type, property, composite, and range indexes.
- Grammar-based Cypher read/write subset with indexed scans, paths, read composition, aggregation, constraints, schema introspection, and registered procedures.
- Bulk and columnar ingestion helpers for Arrow and Polars.
- Typed path and subgraph sampling.
See the full documentation for backend selection, indexing, Cypher syntax, ingestion, sampling, and benchmarks.
Name origin
The name GestaltDB is inspired by Gestalt psychology and the idea that the whole is something more than its parts.
Metadata
Release files for gestaltdb 0.10.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gestaltdb-0.10.2.tar.gz | 290.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gestaltdb-0.10.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 532.0 kB
Release files / gestaltdb-0.10.2.tar.gz
| Download URL | gestaltdb-0.10.2.tar.gz |
|---|---|
| Size | 290.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2372d936730cfdbf1521aed6cb3076f3ab87e67cfa95eb0c96767de94da5e4d1
|
|
BLAKE2b-256 checksum How to use checksums |
1990bc9a7030d678649688bf0a70a2a289758190f37bced229741feff150e0fa
|
| 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 Sep 26, 2026.
Transparency logRelease files / gestaltdb-0.10.2-py3-none-any.whl
| Download URL | gestaltdb-0.10.2-py3-none-any.whl |
|---|---|
| Size | 241.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b12c154f9e731bbc25374c3fe4f064dde3542e8dae18503a50abb5f66a04696c
|
|
BLAKE2b-256 checksum How to use checksums |
c35ba421c0d0f00baf25e622f9d3982cb424450e3490100e84b343520d65efac
|
| 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 Sep 26, 2026.
Transparency log