Skip to main content

OrchidDB for Python

Compile Cypher, Gremlin and SPARQL to SQL, execute through a caller-owned engine, and consume Arrow batches. No DuckDB driver is bundled or imported by the library. The compiler does not touch your data. Graph mapping and schema metadata are explicit.

python -m venv .venv
. .venv/bin/activate
python -m pip install -r examples/requirements.txt
python examples/people.py

The example installs orchiddb[arrow]==0.3.0 from PyPI and its application-owned DuckDB driver. Platform wheels include the compiler for Linux x86_64, macOS ARM64/x86_64, and Windows x86_64; no library path is needed.

For source development on other platforms, build the matching native compiler from OrchidDB-native using NATIVE_REVISION and its pinned CORE_REVISION. Release wheels bundle this compiler for their platform; source installs require the explicit library path. No network downloads happen at import time. ABI and core revision are validated. An explicit development library may report the pinned revision with a -dirty suffix; bundled release libraries require an exact match.

from orchiddb import Compiler, DuckDBEngine, Graph
# connection is your existing DuckDB connection; see examples/people.py for mapping.
graph = Graph(Compiler(), DuckDBEngine(connection), tables=tables, nodes=nodes)
with graph.query_arrow("MATCH (p:Person) WHERE p.name=$name RETURN p.name AS name",
                       parameters={"name": "Ada"}, batch_size=65536) as reader:
    print(reader.schema)
    for batch in reader:
        consume(batch)  # pyarrow.RecordBatch; no row or JSON conversion

The reader closes on context exit, including exceptions. Retained PyArrow batches own their buffers. The adapter never closes the borrowed connection, commits, rolls back, configures extensions, or installs UDFs. Do not reuse that connection until the reader is closed. Overlapping readers through the same adapter fail. Register UDFs yourself and pass their compiler signatures via functions.

graph.plan(query) returns SQL without executing it. Compiler.compile(request) accepts the shared v1 JSON-shaped request; use language="gremlin" or "sparql" with Graph for those languages. SQL support is deliberately narrower than the managed engine's conformance suite. Parameters are specialized into SQL; recompile when values or metadata change. Unsupported queries raise CompilationError.

Implement the ArrowEngine protocol for another backend: provide dialect and a context manager yielding a pyarrow.RecordBatchReader. PostgresEngine and query_federated support PostgreSQL and mixed DuckDB/PostgreSQL execution. Caller controls connections, Arrow allocation, caches and transaction boundaries.

Releases

CI builds pinned native code and runs real Arrow/DuckDB tests. The manual release workflow requires a matching v0.3.0 tag, builds platform wheels, and publishes to PyPI via trusted publishing. Configure PyPI's orchiddb trusted publisher for this repository, workflow release.yml, environment pypi. Version 0.3.0 is published on PyPI.

Licensed under the OrchidDB GPL-3.0-only license.

DuckDB Arrow export follows its Python Arrow API. Arrow batching does not itself guarantee that an engine streams query execution; execution buffering and cancellation remain backend-specific.

RDF vocabulary can reference the same application tables: pass rdf=[...] and optionally dataset="default" to Graph, then use language="sparql". Each rule contains table, subject, predicate, and object term mappings. For example, {"kind":"template","prefix":"urn:person:","columns":["id"]} constructs a subject and {"kind":"literal","column":"name"} exposes a property. These rules require a native compiler built with the shared RDF mapping API.

Generate statistics once

report = graph.generate_statistics()  # bounded reads on graph.engine's session
plan = graph.plan("MATCH (p:Person) WHERE p.name = 'Ada' RETURN p.name")
print(plan.diagnostics)                # estimates and physical-source choices
print(report["report"])               # collection coverage and any skipped work
graph.save_statistics("statistics.json")
graph.clear_statistics()               # subsequent plans use no generated statistics
graph.load_statistics("statistics.json")

Generation is optional and explicit. Shared Rust code decides what to collect and calculates the statistics. Python forwards bounded Arrow IPC batches; it does not implement an estimator. The retained native catalog is automatically used by later compilations, including Cypher, Gremlin, and SPARQL. Regeneration replaces it only after finishing; interruption preserves the previous catalog. Compiler.close() releases the retained catalog and never closes your database.

DuckDBEngine uses the caller's connection and transaction, closes result readers, and interrupts requests at their deadline. Custom adapters can provide statistics_arrow(request) as a context manager yielding Arrow batches, while enforcing timeout_ms, max_rows, and max_bytes during acquisition/reading. Without a bounded adapter, collection reports skipped work. Application-owned collection drivers can also call Compiler.statistics_command(command) directly. No background refresh, profiles, or tuning tiers are involved. The snapshot records its mapping identity; regenerate after changing mappings or source data. Compilation does not read the database.

Graph accepts logical_sources, collection_sources, and representation_sources alongside existing mappings. Full native plan fields are retained in CompiledQuery.diagnostics. A compiler retains one catalog; use a separate compiler instance for each independently analyzed mapping.

Permission pushdown

Pass permission scopes on node mappings and a principal on each protected query. The helpers build provider-neutral request data; the relation must contain effective grants for that principal.

from orchiddb import Authorization, PermissionRelation, PermissionScope

grant_source = "effective_grants"
nodes = [{
    "label": "Document", "table": "documents", "id": "id",
    "properties": {"title": "title", "project_id": "project_id"},
    "permission_scopes": [
        PermissionScope("id", PermissionRelation.flat(grant_source, "document", "view")).to_dict(),
        PermissionScope("project_id", PermissionRelation.flat(grant_source, "project", "view")).to_dict(),
    ],
}]
graph = Graph(compiler, engine, tables=tables, nodes=nodes)
with graph.query_arrow("MATCH (d:Document) RETURN d.title", authorization=Authorization("user", "alice")) as reader:
    result = reader.read_all()

Quickwit and Elasticsearch

Register a remote engine alongside your existing SQL connection and call query_federated with the same engine names as your mapping. Search relationships and remote tables use the shared native HTTP transport; dependent SQL joins still run on your SQL connection.

from orchiddb import Compiler, DuckDBEngine, RemoteEngine, query_federated

with Compiler() as compiler:
    with RemoteEngine(compiler, "quickwit", "http://localhost:7280",
                      page_size=1000) as search:
        engines = {"db": DuckDBEngine(connection), "search": search}
        with query_federated(compiler, request, engines) as reader:
            table = reader.read_all()

Use "elasticsearch" and its endpoint for Elasticsearch. request contains your engine registry, tables, graph mappings, and query; see the search engine guide for complete mappings and queries. Install the arrow extra. Credentials belong in RemoteEngine(..., authentication={"type": "bearer", "token": token}), not in the query mapping. Basic authentication and API keys are supported too. Sessions are caller-owned: federation closes result readers but never your SQL connection or remote session. HTTP failures and incomplete results raise errors. Calls are synchronous; use a worker thread in an asynchronous application.

Custom remote adapters can implement dialect and execute_requests(requests, columns) as a context manager yielding an Arrow reader. This retains nested types, large integers, and JSON/SQL null distinctions. For live integration tests, set ORCHIDDB_REMOTE_FIXTURE to the shared release fixture JSON and run pytest tests/test_remote_engines.py.

Metadata

Release files for orchiddb 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for orchiddb 0.3.0
File Size Uploaded Provenance Actions
orchiddb-0.3.0.tar.gz 38.5 kB With provenance Details for orchiddb-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for orchiddb 0.3.0
File Actions
orchiddb-0.3.0-py3-none-manylinux_2_34_x86_64.whl Python 3 none Linux glibc 2.34+ x86-64 Details for orchiddb-0.3.0-py3-none-manylinux_2_34_x86_64.whl
orchiddb-0.3.0-py3-none-manylinux_2_34_aarch64.whl Python 3 none Linux glibc 2.34+ ARM64 Details for orchiddb-0.3.0-py3-none-manylinux_2_34_aarch64.whl
orchiddb-0.3.0-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details for orchiddb-0.3.0-py3-none-macosx_11_0_x86_64.whl
orchiddb-0.3.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for orchiddb-0.3.0-py3-none-macosx_11_0_arm64.whl

Total release size: 99.9 MB

Release files / orchiddb-0.3.0.tar.gz

Download URL orchiddb-0.3.0.tar.gz
Size 38.5 kB
Tags Source
SHA-256 checksum
How to use checksums
db452a76485f63a37ea0230a4e34661c08c2fea4008dffa18947191b1d19e1f1
BLAKE2b-256 checksum
How to use checksums
391bf6d77e9a7a2adbc0c48b770643a0661cb307adea015890aeb63b4ea9e410
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 Oct 5, 2026.

Transparency log

Release files / orchiddb-0.3.0-py3-none-manylinux_2_34_x86_64.whl

Download URL orchiddb-0.3.0-py3-none-manylinux_2_34_x86_64.whl
Size 26.9 MB
Tags Linux glibc 2.34+ x86-64 Python 3
SHA-256 checksum
How to use checksums
39a04e6ba9a19ef3c308975ffa168c13561c143ff6637c8b1190a3baa630946f
BLAKE2b-256 checksum
How to use checksums
3729de9bd20861bb6bfeace631ea20d8877f674eaeefad0e9a1409aac62768fc
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 Oct 5, 2026.

Transparency log

Release files / orchiddb-0.3.0-py3-none-manylinux_2_34_aarch64.whl

Download URL orchiddb-0.3.0-py3-none-manylinux_2_34_aarch64.whl
Size 24.7 MB
Tags Linux glibc 2.34+ ARM64 Python 3
SHA-256 checksum
How to use checksums
70aeb45693609f2ae88d1f42110dafa245de407b552017a67cb8095b1ef08e88
BLAKE2b-256 checksum
How to use checksums
08c2a2698b761cd4eb29b0750446ad9873b1e12c661e608c5b3a1d33e3426dd4
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 Oct 5, 2026.

Transparency log

Release files / orchiddb-0.3.0-py3-none-macosx_11_0_x86_64.whl

Download URL orchiddb-0.3.0-py3-none-macosx_11_0_x86_64.whl
Size 25.2 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
118773125993d3245215d3aa286e6b114c696775da405c7bd8da4e111fcc92a1
BLAKE2b-256 checksum
How to use checksums
7ad5726b0a19eed191fba414f33eeea5d8ec823092193f720487111f668f1ea5
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 Oct 5, 2026.

Transparency log

Release files / orchiddb-0.3.0-py3-none-macosx_11_0_arm64.whl

Download URL orchiddb-0.3.0-py3-none-macosx_11_0_arm64.whl
Size 23.0 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
121c8f495b355794b8e1aae0d619e24f80ae41ee31cf79a0f6e83ee5ef2acd93
BLAKE2b-256 checksum
How to use checksums
460bc3293640aac1534ce295fdbd2859460e317b7f6b547a62aebbb873ef3455
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 Oct 5, 2026.

Transparency log

Security for orchiddb 0.3.0

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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for orchiddb-0.3.0.tar.gz

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 Oct 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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