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.1

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.1
File Size Uploaded Provenance Actions
pygtvdb-0.1.1.tar.gz 33.9 kB Without provenance Details for pygtvdb-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 63.7 kB

Release files / pygtvdb-0.1.1.tar.gz

Download URL pygtvdb-0.1.1.tar.gz
Size 33.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8b8f440ad9aef71a488acc176f41c4c234696106b3f1dade55f7890d76115ed3
BLAKE2b-256 checksum
How to use checksums
a07d3b1db882739da164c79cf2f831ca2dba523b10631cdfa02672a34dd1d4bd
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.1-py3-none-any.whl

Download URL pygtvdb-0.1.1-py3-none-any.whl
Size 29.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efe454bf27e68ef73e96f4ee2839d8f89a8de7e85df99dd8440d681caeffb811
BLAKE2b-256 checksum
How to use checksums
1a3d4805d7cb9791d0fc32d1375bdbedc113a97536bc8e3c80345fe21725b5b7
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.1

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