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.1.0 from PyPI and its application-owned DuckDB driver. The wheel includes the compiler for macOS 26+ ARM64; 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.1.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.1.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()

Metadata

Release files for orchiddb 0.2.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.2.0
File Size Uploaded Provenance Actions
orchiddb-0.2.0.tar.gz 34.0 kB With provenance Details for orchiddb-0.2.0.tar.gz

Built distributions (wheels)

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

Total release size: 88.7 MB

Release files / orchiddb-0.2.0.tar.gz

Download URL orchiddb-0.2.0.tar.gz
Size 34.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f8fe9353cf43d1eb0df7c3b7a1c09eb247bf3b7ddb1b3ec6ed36d883365b0ffd
BLAKE2b-256 checksum
How to use checksums
d35fb1c12c0a041410ce7308ce89ad4d4296f83cb6e24fb12839cb12d1a6f5c5
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 3, 2026.

Transparency log

Release files / orchiddb-0.2.0-py3-none-win_amd64.whl

Download URL orchiddb-0.2.0-py3-none-win_amd64.whl
Size 23.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
39570c5877edfcecee35eb6d7067c309f5d6b8cdc4b87d9f851ffb33cbc91c97
BLAKE2b-256 checksum
How to use checksums
f10386287a9806eeb6747cac5f8f1977ba8e1923cec876439f7bce3950d9544d
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 3, 2026.

Transparency log

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

Download URL orchiddb-0.2.0-py3-none-manylinux_2_34_x86_64.whl
Size 23.1 MB
Tags Linux glibc 2.34+ x86-64 Python 3
SHA-256 checksum
How to use checksums
5508a84b840eba17f46bbc28bdf31ed57c889cfc000c4e3f0de1d914345d2f5f
BLAKE2b-256 checksum
How to use checksums
59b29344974c7dd44928dff23ae76123b7152e2c35cfb39e93eb980a6d26cfec
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 3, 2026.

Transparency log

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

Download URL orchiddb-0.2.0-py3-none-macosx_11_0_x86_64.whl
Size 21.9 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
c732bd6f82aa719884c2155770c98ee97bf904be336b2353f4be2f8d2865c86d
BLAKE2b-256 checksum
How to use checksums
838d28e0555f2ebb4e26c46d26af5b3717b62d612e83943f5113f360b3210dc3
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 3, 2026.

Transparency log

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

Download URL orchiddb-0.2.0-py3-none-macosx_11_0_arm64.whl
Size 20.0 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
25d8d8535c2967266829cf76bacd18e60fb543a2004ff5606b11e2c173cf710e
BLAKE2b-256 checksum
How to use checksums
af2c97be0ee9fa788bebabe265d626cb5419efc9273899ecfca069eeb40c8722
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 3, 2026.

Transparency log

Security for orchiddb 0.2.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.2.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 3, 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