Skip to main content

sqlitegraph

Python bindings to sqlitegraph — an embedded graph database with 35+ graph algorithms and HNSW vector search. Rust core, no server required, single .db or .graph file.

Install

pip install sqlitegraph

Quick start

from sqlitegraph import Graph

g = Graph.open_in_memory()
alice = g.add_node(kind="User", name="Alice", data={"age": 30})
order = g.add_node(kind="Order", name="Order-123")
g.add_edge(alice, order, "placed")

print(g.neighbors(alice))

Query language

Graph.query() exposes the same Cypher-inspired language as the CLI:

from sqlitegraph import Graph

g = Graph.open_in_memory()
alice = g.add_node(kind="User", name="Alice", data={"age": 30})
bob = g.add_node(kind="User", name="Bob", data={"age": 31})
g.add_edge(alice, bob, "KNOWS")

result = g.query("MATCH (a:User)-[:KNOWS]->(b:User) RETURN a.name, b.name")
print(result["results"])

Supported query features include node scans, edge traversal, multi-hop chains, star/multi-pattern joins, variable-depth edges, WHERE with regex/numeric operators and parentheses, LIMIT, CREATE, SET, DELETE, and HNSW vector search through CALL db.index.vector.queryNodes(...).

Algorithms

from sqlitegraph import Graph

g = Graph.open_in_memory()
a = g.add_node(kind="Page", name="A")
b = g.add_node(kind="Page", name="B")
c = g.add_node(kind="Page", name="C")
g.add_edge(a, b, "LINKS")
g.add_edge(b, c, "LINKS")
g.add_edge(c, a, "LINKS")

print(g.pagerank(iterations=20))
print(g.connected_components())
print(g.strongly_connected_components())
print(g.label_propagation(50))
print(g.find_cycles(10))
print(g.dominators(a))

critical_path() is also available for directed acyclic graphs and returns {"path": [...], "distance": float, "path_length": int}.

HNSW vector search

from sqlitegraph import Graph

g = Graph.open_in_memory()
idx = g.create_hnsw_index("embeddings", dimension=3, metric="cosine")

idx.insert_vector([1.0, 0.8, 0.1], {"label": "graph databases"})
idx.insert_vector([0.1, 0.2, 1.0], {"label": "baking"})

print(idx.search([1.0, 0.9, 0.0], 1))
print(g.list_hnsw_indexes())

g.delete_hnsw_index("embeddings")

Examples

The examples/ directory contains runnable scripts:

Example What it shows
01_basic_crud.py Nodes, edges, update, delete, query by kind/pattern, degrees
02_graph_algorithms.py BFS, k-hop, shortest path, PageRank, Louvain & label-propagation communities, connected components (WCC), strongly-connected components (SCC), cycle search, dominator tree, critical path
03_vector_search.py HNSW index creation, insert, search, bulk insert, index listing
04_social_network.py Realistic network: influencers (PageRank), communities, connection paths, mutual follows
05_file_backed.py Persistent Graph.open(path), checkpoint, reopen, cleanup
06_hybrid_sqlite_hnsw_query.py sqlite3 application rows + sqlitegraph metadata + HNSW + Graph.query() expansion

Run any example from the repo root:

cd sqlitegraph-py
source .venv/bin/activate
python examples/01_basic_crud.py

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlitegraph-0.5.6.tar.gz (1.2 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

sqlitegraph-0.5.6-cp310-abi3-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.10+Windows x86-64

sqlitegraph-0.5.6-cp310-abi3-manylinux_2_28_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

sqlitegraph-0.5.6-cp310-abi3-manylinux_2_28_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

sqlitegraph-0.5.6-cp310-abi3-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

sqlitegraph-0.5.6-cp310-abi3-macosx_10_12_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file sqlitegraph-0.5.6.tar.gz.

File metadata

  • Download URL: sqlitegraph-0.5.6.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sqlitegraph-0.5.6.tar.gz
Algorithm Hash digest
SHA256 0a7d6b424752924d471a8913efabb0143724115bc32ca2644c7763df2ea8bb1d
MD5 99b9985ef0286fd7a265b9d488bdc077
BLAKE2b-256 059a28eba987fe2547ad0f7d3c84645b026f6dffc47ec308acbfa23dad8479f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlitegraph-0.5.6.tar.gz:

Publisher: wheels.yml on oldnordic/sqlitegraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sqlitegraph-0.5.6-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: sqlitegraph-0.5.6-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sqlitegraph-0.5.6-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5defa4c5f44060f1d595a9e479e10d673de21f9c0cd8044e58bf51ef4ca22355
MD5 12d4122a926026da269b54fede9523ce
BLAKE2b-256 7c9dd29b2209a3765f4108a9fbb3ad7577371fca9c88d6a6440927d23a062826

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlitegraph-0.5.6-cp310-abi3-win_amd64.whl:

Publisher: wheels.yml on oldnordic/sqlitegraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sqlitegraph-0.5.6-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for sqlitegraph-0.5.6-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5a8c2f3abe6db8b8a1b30418529eb35b594f94a5e1f40f005092917db7b16774
MD5 d482425c31c8cfee9fbfc912a49dd21e
BLAKE2b-256 83541a4146044a677c13b2e7cab0d7464da095c4cfb413c31694d0534dbf7a7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlitegraph-0.5.6-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on oldnordic/sqlitegraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sqlitegraph-0.5.6-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for sqlitegraph-0.5.6-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7a3d95b74df7604be85ae8c71f48a11740bb2fc48b91c7119c704c9fa53774e3
MD5 5147ab3bfb9d35f50443d191976b6a1f
BLAKE2b-256 f6407c1e2f8934f67efea9534cf3c902f09a35984556a0d9d6645877a3153dab

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlitegraph-0.5.6-cp310-abi3-manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on oldnordic/sqlitegraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sqlitegraph-0.5.6-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sqlitegraph-0.5.6-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c1c173c18ac7e791b150cf4d268a2672b70eac5c41d048ec55815530de5a8b5
MD5 3a93d09f45d6f1dc5d924c4a3fa1b260
BLAKE2b-256 bb2b07272c7e0fa12c143ab1a56bf1d798f8a6d4032fa99c4894072e8fd1e194

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlitegraph-0.5.6-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: wheels.yml on oldnordic/sqlitegraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sqlitegraph-0.5.6-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for sqlitegraph-0.5.6-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d9fd990c756ff2344b2504805046ef6719d7e35430ed19afa612729f825aebc0
MD5 2bf298f59af3dcd5c9ab734ebc6f7cf2
BLAKE2b-256 0f27df6d7326599712261e972f015e83a34974d1f0f2067464ddf71fdacc81b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlitegraph-0.5.6-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: wheels.yml on oldnordic/sqlitegraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page