Skip to main content

gtvdb (Python)

DB-API 2.0 driver for the gtv temporal-graph engine. Pure Python over gRPC — nothing to compile, no platform wheel, no protoc on the user's machine.

pip install pygtvdb            # or: pip install pygtvdb[pandas]

The PyPI distribution is named pygtvdb (the shorter gtvdb name was unavailable at publish time), but you still import gtvdb in Python — distribution name and import name are deliberately decoupled, so the code below is unchanged from earlier previews.

Requires Python 3.9+ and a reachable engine. The driver is a client only: it does not embed the engine, and it cannot create one. The quickest engine is the published container image (no Rust toolchain, no git clone):

docker run --rm -p 50051:50051 -e GTV_ADDR=0.0.0.0:50051 \
  ghcr.io/jacalwu/gtvdb-core:0.1.0 gtv-demo-server
# in another shell: pip install pygtvdb && python your_client.py

The image also ships gtv, the zero-extension SQL REPL (docker run --rm -it ghcr.io/jacalwu/gtvdb-core:0.1.0). Linux binaries are on the GitHub release tagged v*. The gtv-demo-server serves one immutable snapshot for protocol development; the production store-backed engine (gtv-server) lives in the companion gtvdb_ext repository. From a source checkout, cargo run -p gtv-engine --example serve_demo works too.

import gtvdb

con = gtvdb.connect("gtv://127.0.0.1:50051")
cur = con.cursor()
cur.execute("SELECT * FROM numbers WHERE n <= ?", (3,))
print(cur.fetchall())          # [(1, 1.0), (2, 4.0), (3, 9.0)]
print(cur.description[0][0])   # 'n'
con.close()

Works with pandas out of the box:

import pandas as pd
pd.read_sql("SELECT * FROM prices ORDER BY t", con)

Pinning business time

as_of is the engine's "answer as of T", and it belongs to the connection, not to each query — the equivalent of opening a kdb+ session at a timestamp:

con = gtvdb.connect("gtv://host:50051", as_of=1_700_000_000_000_000_000)
con.cursor().execute("SELECT count(*) FROM positions").fetchall()

at_open = con.pin(as_of=1_700_000_000_000_000_000)   # same channel, new pin

Evidence, for workloads that need it

DB-API cannot express "this empty result proves nothing", so the cursor keeps the engine's answer alongside the rows:

cur.execute("SELECT * FROM edges WHERE src = ?", (99,))
cur.fetchall()        # []
cur.tri_state         # 'no_match'  -> absence is proven
cur.receipt           # full QueryReceipt: snapshot, as_of, freshness

tri_state == "incomplete" (budget or deadline hit) means the empty result proves nothing. cur.is_conclusive is False for an old server that cannot compute a tri-state at all.

What it is not

  • Read-only. commit() / rollback() are no-ops; DML is refused by the engine, not faked by the driver. Writes belong to an RDBMS or Redis that refreshes into the store.
  • Not a wire format of its own. It speaks gtvquery.QueryService v1 (crates/gtv-proto/proto/gtvquery.proto), the same contract the Rust client uses. ? parameters are rendered client-side into typed literals, because protocol v1 has no bind slots.

Development

pip install -e ./python                 # from the gtvdb_core repo root
python python/gen_stubs.py              # regenerate gtvdb/_stubs from the .proto
python python/gen_stubs.py --check      # CI: fail if stubs drift
python -m pytest python/tests           # unit tests, no server needed

Releasing

The version lives in exactly one place, gtvdb/_version.py; pyproject.toml reads it back rather than repeating it. Before an upload:

python python/check_release.py          # licence copy, stub freshness, tests,
                                        # metadata, artefact contents, name on PyPI

Pushing a py-v* tag publishes through GitHub Actions with PyPI trusted publishing, so no token is stored anywhere. The full procedure — including the first-release bootstrap, TestPyPI rehearsal, and why a version number can never be reused — is in PUBLISHING.md.

Metadata

Release files for pygtvdb 0.1.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 pygtvdb 0.1.0
File Size Uploaded Provenance Actions
pygtvdb-0.1.0.tar.gz 33.9 kB Without provenance Details for pygtvdb-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pygtvdb 0.1.0
File Interpreter ABI Platform Actions
pygtvdb-0.1.0-py3-none-any.whl Python 3 none any Details for pygtvdb-0.1.0-py3-none-any.whl

Total release size: 63.6 kB

Release files / pygtvdb-0.1.0.tar.gz

Download URL pygtvdb-0.1.0.tar.gz
Size 33.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e88fadcf4d65181047877961072bab9921ba2dc4ab9736ae3f3194772f6d9b89
BLAKE2b-256 checksum
How to use checksums
bf0339543c7526e2823e7b73f79cff40cd2817b38198fbfd0f9bbc44b37475df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / pygtvdb-0.1.0-py3-none-any.whl

Download URL pygtvdb-0.1.0-py3-none-any.whl
Size 29.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4378efbfdb948ac5926735e1f8bc5398ecf76ef003421056d95213ab5b656737
BLAKE2b-256 checksum
How to use checksums
9bc7e2f737554ec55d75ffcb2358bc97be45b2214a2f791b4f99c3b667af3e82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for pygtvdb 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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