Skip to main content

HelixDB Python SDK

The Python SDK pairs an idiomatic query-builder DSL with a dependency-free client for sending HelixDB queries to POST /v1/query or executing them against an embedded database.

from helixdb import Client, Predicate, g, read_batch

query = (
    read_batch()
    .var_as(
        "users",
        g()
        .n_with_label("User")
        .where(Predicate.eq("status", "active"))
        .limit(25)
        .value_map(["$id", "name", "status"]),
    )
    .returning(["users"])
)

request = query.to_query_request()
result = Client("http://localhost:6969").query(request)

The DSL emits the same query JSON AST as the Rust, TypeScript, and Go SDKs. Python methods use snake_case; compatibility aliases such as nWithLabel and valueMap are also available for users translating TypeScript examples directly.

Query Parameters

from helixdb import Predicate, define_params, g, param, read_batch

params = define_params({
    "tenant_id": param.string(),
    "limit": param.i64(),
})

query = (
    read_batch()
    .var_as(
        "users",
        g()
        .n_with_label("User")
        .where(Predicate.eq("tenantId", params.tenant_id))
        .limit(params.limit)
        .value_map(["$id", "name", "tenantId"]),
    )
    .returning(["users"])
)

body = query.to_query_json(
    params,
    {"tenant_id": "acme", "limit": 10},
    query_name="find_users",
)

Row Bindings

Use bind(...) when a multi-hop traversal needs to keep earlier elements correlated with later results. project_distinct_bindings(...) emits one row per projected tuple.

from helixdb import BindingProjection, g, read_batch, sub

query = (
    read_batch()
    .var_as(
        "workloads",
        g()
        .n_with_label("Service")
        .bind("service")
        .optional(sub().in_("CREATES").bind("deployment"))
        .union([sub().in_("MANAGES").bind("owner"), sub().out("ROUTES_TO").bind("workload")])
        .project_distinct_bindings([
            BindingProjection.binding("service", "$id", "service_id"),
            BindingProjection.coalesce(
                [
                    BindingProjection.binding_ref("deployment", "$id"),
                    BindingProjection.binding_ref("owner", "$id"),
                    BindingProjection.binding_ref("workload", "$id"),
                ],
                "workload_id",
            ),
        ]),
    )
    .returning(["workloads"])
)

Embedded Client

Install the SDK and matching native runtime:

python -m pip install "helix-db==0.3.0" "helix-db-embedded==0.3.0"
from helixdb import Client, InMemory

client = Client.embedded(InMemory("app"))
try:
    response = client.query(request)
finally:
    client.close()

Cache profiles are fixed when the handle opens. Vector-memory-only mode disables SlateDB and object-store caches, not canonical persistence.

from helixdb import EmbeddedCacheConfig, VectorMemoryOnly

client = Client.embedded(
    InMemory("app"),
    cache=EmbeddedCacheConfig(256 * 1024 * 1024, VectorMemoryOnly()),
)

Client.embedded_reader(...) opens an existing disk or object-storage database read-only. Stored routes and query bundles are not supported.

Native graph algorithms

from helixdb import Client, SourcePredicate, g
from helixdb.graph import BetweennessOptions, GraphSelection

client = Client()
selection = GraphSelection(
    node_traversal=g().n_where(SourcePredicate.has_key("$id")),
    edge_traversal=g().e_where(SourcePredicate.has_key("$id")),
    direction="directed",
    allow_full_scan=True,
)
graph = client.graph(selection)
scores = graph.betweenness_centrality(BetweennessOptions.graphify_default())

The returned object retains the immutable Rust topology. Every accessor and algorithm runs locally without another Helix read. Native wheels are required for this graph API and embedded mode; query-only imports remain dependency free.

Run the SDK tests from the repository root:

PYTHONPATH=sdks/python/src python -m unittest discover sdks/python/tests

Download files

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

Source Distribution

helix_db-0.3.0.tar.gz (43.8 kB view details)

Uploaded Source

Built Distribution

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

helix_db-0.3.0-py3-none-any.whl (37.2 kB view details)

Uploaded Python 3

File details

Details for the file helix_db-0.3.0.tar.gz.

File metadata

  • Download URL: helix_db-0.3.0.tar.gz
  • Upload date:
  • Size: 43.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for helix_db-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3eda401a227fc713cff7b011abf7eb17b869a044ba09497ce433e4ae32c0b22a
MD5 6b2a9fe65084c579cee6f2a63d3590c7
BLAKE2b-256 609fc280d389460b5d0ca3d8c03d62a4414bb837cf28d2c7c7076e68c95afb61

See more details on using hashes here.

File details

Details for the file helix_db-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: helix_db-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 37.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for helix_db-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1dba9e5a849d388eef10c6c8caad0dd561101ef4a3952cf3e4b47fa279180784
MD5 1c0a54c3e27b445eb149a6cc3f197d1d
BLAKE2b-256 fa5bfa77503a3e47fd52979855fd24f2a5b4c921e8e0d93e5058af6b478c3c62

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

This release

0.3.0 This release

2 files

0.1.0

2 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