Skip to main content

A high-performance, embeddable graph database with Python bindings

Project description

grafeo

Python bindings for Grafeo, a high-performance, embeddable graph database with a Rust core.

Installation

uv add grafeo
# or: pip install grafeo

Quick Start

from grafeo import GrafeoDB

# In-memory database
db = GrafeoDB()

# Or persistent
# db = GrafeoDB("./my-graph")

# Create nodes
db.execute("INSERT (:Person {name: 'Alix', age: 30})")
db.execute("INSERT (:Person {name: 'Gus', age: 25})")
db.execute("INSERT (:Person {name: 'Alix'})-[:KNOWS]->(:Person {name: 'Gus'})")

# Query the graph
result = db.execute("MATCH (p:Person) WHERE p.age > 20 RETURN p.name, p.age")
for row in result:
    print(row)

API Overview

Database

db = GrafeoDB()              # in-memory
db = GrafeoDB("./path")      # persistent
db = GrafeoDB.open("./path") # open existing

db.node_count   # number of nodes
db.edge_count   # number of edges

Query Languages

result = db.execute(gql)                        # GQL (ISO standard)
result = db.execute(gql, {"name": "Alix"})     # GQL with parameters
result = db.execute_cypher(query)               # Cypher
result = db.execute_sparql(query)               # SPARQL
result = db.execute_gremlin(query)              # Gremlin
result = db.execute_graphql(query)              # GraphQL

Node & Edge CRUD

node = db.create_node(["Person"], {"name": "Alix", "age": 30})
edge = db.create_edge(source_id, target_id, "KNOWS", {"since": 2024})

n = db.get_node(node_id)   # Node or None
e = db.get_edge(edge_id)   # Edge or None

db.set_node_property(node_id, "key", "value")
db.set_edge_property(edge_id, "key", "value")

db.delete_node(node_id)
db.delete_edge(edge_id)

Transactions

# Context manager (auto-rollback on exception)
with db.begin_transaction() as tx:
    tx.execute("INSERT (:Person {name: 'Harm'})")
    tx.commit()

# With isolation levels
from grafeo import IsolationLevel
with db.begin_transaction(IsolationLevel.SERIALIZABLE) as tx:
    tx.execute("MATCH (n:Person) SET n.verified = true")
    tx.commit()

QueryResult

result = db.execute("MATCH (n:Person) RETURN n.name, n.age")

result.columns          # column names
len(result)             # row count
result.execution_time   # execution time (seconds)

for row in result:      # iterate rows
    print(row)

result[0]               # access by index
result.scalar()         # first column of first row

Vector Search

# Create an HNSW index
db.create_vector_index("Document", "embedding", dimensions=384)

# Insert vectors
node = db.create_node(["Document"], {"embedding": [0.1, 0.2, ...]})

# Search
results = db.vector_search("Document", "embedding", query_vector, k=10)

Features

  • GQL, Cypher, SPARQL, Gremlin and GraphQL query languages
  • Full node/edge CRUD with native Python types
  • ACID transactions with configurable isolation levels
  • HNSW vector similarity search
  • Property indexes for fast lookups
  • Async support via asyncio
  • Type stubs included

Links

License

Apache-2.0

Project details


Download files

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

Source Distribution

grafeo-0.5.35.tar.gz (2.0 MB view details)

Uploaded Source

Built Distributions

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

grafeo-0.5.35-cp312-abi3-win_amd64.whl (4.5 MB view details)

Uploaded CPython 3.12+Windows x86-64

grafeo-0.5.35-cp312-abi3-win32.whl (4.1 MB view details)

Uploaded CPython 3.12+Windows x86

grafeo-0.5.35-cp312-abi3-musllinux_1_2_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ x86-64

grafeo-0.5.35-cp312-abi3-musllinux_1_2_aarch64.whl (4.7 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ ARM64

grafeo-0.5.35-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

grafeo-0.5.35-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.5 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

grafeo-0.5.35-cp312-abi3-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

grafeo-0.5.35-cp312-abi3-macosx_10_12_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

Details for the file grafeo-0.5.35.tar.gz.

File metadata

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

File hashes

Hashes for grafeo-0.5.35.tar.gz
Algorithm Hash digest
SHA256 1df2096a8852edccb6d10d77b046ab1672ffc301dd47e06c131cc63adb382f3e
MD5 84ec68334136c079b79fc6db4c13f475
BLAKE2b-256 23bce11b1965c553a838616b9fff4e74b63da78d60ac7c945b5d16c999466938

See more details on using hashes here.

Provenance

The following attestation bundles were made for grafeo-0.5.35.tar.gz:

Publisher: pypi.yml on GrafeoDB/grafeo

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

File details

Details for the file grafeo-0.5.35-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: grafeo-0.5.35-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for grafeo-0.5.35-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f5802a9e174b1f6110c7fab553e6f3f0c191b9e8428e9799b95f66be08169bad
MD5 7e36e059747ac296a9e829d420473bfe
BLAKE2b-256 20670c7c02383adfb58b4babd8de23427ff39a031af077fa03a23d2f01d0c47c

See more details on using hashes here.

Provenance

The following attestation bundles were made for grafeo-0.5.35-cp312-abi3-win_amd64.whl:

Publisher: pypi.yml on GrafeoDB/grafeo

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

File details

Details for the file grafeo-0.5.35-cp312-abi3-win32.whl.

File metadata

  • Download URL: grafeo-0.5.35-cp312-abi3-win32.whl
  • Upload date:
  • Size: 4.1 MB
  • Tags: CPython 3.12+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for grafeo-0.5.35-cp312-abi3-win32.whl
Algorithm Hash digest
SHA256 43bb2a6634270074a46e0123eec57f9e189f8e3b35304a0993d7584e04088792
MD5 7536489ef3b5acb5ebff6318d18c43e7
BLAKE2b-256 31fefd3e248d06c9ad9a7e992fa50013ee107bcbf6da36eb916486e7be6c8cfb

See more details on using hashes here.

Provenance

The following attestation bundles were made for grafeo-0.5.35-cp312-abi3-win32.whl:

Publisher: pypi.yml on GrafeoDB/grafeo

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

File details

Details for the file grafeo-0.5.35-cp312-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for grafeo-0.5.35-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6f8a51db0492157dcc021988e4d1a6cfdf9c80b788b37a1e4d332813e119e198
MD5 61b7064a98e57a6e84d0721a64095dd3
BLAKE2b-256 894ae0228ec02485f837f316cda3e37329652d77edfb38a77f6960fad573dd8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for grafeo-0.5.35-cp312-abi3-musllinux_1_2_x86_64.whl:

Publisher: pypi.yml on GrafeoDB/grafeo

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

File details

Details for the file grafeo-0.5.35-cp312-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for grafeo-0.5.35-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8903e80a2c11e5752aa00937b20a164b085646744f6f28118ca922e292fe6c76
MD5 02d66b8511e3a8271989f1880e3edcc5
BLAKE2b-256 59e3ee10923677a345611d108883f847a44133f4b0d19b7f0208e92298066ec6

See more details on using hashes here.

Provenance

The following attestation bundles were made for grafeo-0.5.35-cp312-abi3-musllinux_1_2_aarch64.whl:

Publisher: pypi.yml on GrafeoDB/grafeo

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

File details

Details for the file grafeo-0.5.35-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for grafeo-0.5.35-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bdd741717c655d9d996df92aa923b1387f91aec70ed31b6fc86aa6529617ed8f
MD5 ee6f4704e1d66d3e4abce850df2d9210
BLAKE2b-256 6b2b9685594dd80c9b80d3a7a981d3a09bc157dd16cea2bd079a7f861821e518

See more details on using hashes here.

Provenance

The following attestation bundles were made for grafeo-0.5.35-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi.yml on GrafeoDB/grafeo

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

File details

Details for the file grafeo-0.5.35-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for grafeo-0.5.35-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c729c868e738437ecc28234bb954b7159571f5831a179a11bc8aada39414bc90
MD5 e590e714fbb2d4b7153729eac29a5274
BLAKE2b-256 ebfb6a9658d66b84a8e4127c25d973ceee40d787fb2991b08d61194520cc586f

See more details on using hashes here.

Provenance

The following attestation bundles were made for grafeo-0.5.35-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: pypi.yml on GrafeoDB/grafeo

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

File details

Details for the file grafeo-0.5.35-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for grafeo-0.5.35-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b7f5b3a242f1362551120b3551466ef7678e3140eb9b16f4895aa5ceaeab0831
MD5 e04ced774bbff090e22cfccbb760fc67
BLAKE2b-256 ea28bbae0887e4df2bca15f8c06dc9a004d12ac4ff226067cc38c7b5c3f69d7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for grafeo-0.5.35-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: pypi.yml on GrafeoDB/grafeo

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

File details

Details for the file grafeo-0.5.35-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for grafeo-0.5.35-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 bf534b99e3db20ebf694b7093d872de465f053587c4fb6e1420faeb16c7ef337
MD5 d30d024d89a4928a61832de0a818e4fb
BLAKE2b-256 148e07c8359a30c4f3249dab7c0585d8921a44347370b8f5eb4180fceeba2833

See more details on using hashes here.

Provenance

The following attestation bundles were made for grafeo-0.5.35-cp312-abi3-macosx_10_12_x86_64.whl:

Publisher: pypi.yml on GrafeoDB/grafeo

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 Pingdom Monitoring Sentry Error logging StatusPage Status page