Skip to main content

Python SDK for HelixDB dynamic query DSL and client

Project description

HelixDB Python SDK

The Python SDK pairs an idiomatic query-builder DSL with a small dependency-free HTTP client for sending dynamic HelixDB queries to POST /v1/query.

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_dynamic_request()
result = Client("http://localhost:6969").query().dynamic(request).send()

The DSL emits the same dynamic-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.

Dynamic 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_dynamic_json(
    params,
    {"tenant_id": "acme", "limit": 10},
    query_name="find_users",
)

Stored Queries

from helixdb import Client

client = Client("https://cluster.helix-db.com", api_key="hx_secret")
response = client.query().body({"tenant_id": "acme"}).stored("find_users").send()

Run the SDK tests from the repository root:

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

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

helix_db-0.1.0.tar.gz (23.9 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.1.0-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: helix_db-0.1.0.tar.gz
  • Upload date:
  • Size: 23.9 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.1.0.tar.gz
Algorithm Hash digest
SHA256 70be204ca633fa6071ec84fba48a8e537af581b3d78743ecea8efa999b0894dc
MD5 1e802426e3e0a7362e1e4788ce630517
BLAKE2b-256 4ec178709ab2bf9d0d0c35b276f4bc9d4ca99f3e8dc35e5060b761ebbe710c23

See more details on using hashes here.

File details

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

File metadata

  • Download URL: helix_db-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.4 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7944d9873101443aa3bfc504b39ef2226da2d93cddf15d7574b04c9082be4af2
MD5 fda2aceb816da437c2b7dac97675f914
BLAKE2b-256 0d25e39ae863363c337fcac71196ff92259355c81246a6da381a252c4f9397a2

See more details on using hashes here.

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