datastreamdb
Python bindings for DataStreamDB — embedded, multi-instance graph database. This package ships an abi3 wheel for Python 3.10+ on Linux x64 (glibc).
pip install datastreamdb
Full developer guide: https://fab679.github.io/datastreamdb/embedding/python/
Quick start
import json
from datastreamdb import Instance, version
print(version()) # "0.2.0"
db = Instance("{}") # isolated in-memory instance
db.put("user:1", json.dumps({"name": "Ada", "age": 36}))
raw = db.get("user:1")
print(None if raw is None else json.loads(raw)["name"]) # Ada
Persistent instance:
db = Instance(json.dumps({
"data_dir": "/var/lib/app/graph-a",
"tenant": "app",
}))
data_dir takes an exclusive lock; a second open of the same directory fails
until the first closes. tenant is a label, not an isolation boundary.
Query with prefix scans
result = json.loads(db.execute(json.dumps({
"op": "scan",
"prefix": "user:",
"limit": 100,
})))
for pair in result["pairs"]:
print(pair["key"], json.loads(pair["value"]))
Keys are returned in lexicographic order. limit defaults to 1000 and is
clamped to 100,000. There is no continuation cursor in 0.2.0.
Atomic writes
result = json.loads(db.execute(json.dumps({
"op": "batch",
"puts": [
{"key": "user:1", "value": json.dumps({"name": "Ada"})},
{"key": "user:2", "value": json.dumps({"name": "Bob"})},
],
"deletes": ["user:3"],
})))
print(result["applied"]) # 3
API
| Method | Description |
|---|---|
Instance(config_json) |
Open a memory or persistent instance. |
id() |
Unique instance id. |
backend() |
"memory" or "fjall". |
put(key, value) |
Upsert a UTF-8 value. |
get(key) |
Read a UTF-8 value, or None. |
execute(request) |
ping, put, get, delete, scan, batch, flush. |
version() |
Binding/engine version. |
Values are strings in the raw KV API. Serialize JSON documents with
json.dumps; base64-encode binary data. The GIL is released around every
engine call.
DQL and GraphQL
db.dql_alter("name: string @index(exact) .\nfriend: [uid] @reverse .\ntype Person {\n name\n friend\n}")
db.dql_mutate('{ set { _:a <name> "Ada" .\n_:b <name> "Bob" .\n_:a <friend> _:b .\n} }')
print(db.dql_query('{ people(func: eq(name, "Ada")) { name friend { name } } }'))
db.set_graphql_schema("type Person { id: ID! name: String @search(by: [term]) }")
print(db.graphql("{ queryPerson { name } }"))
GraphQL subscriptions are poll-based via graphql_subscribe, graphql_next,
and graphql_unsubscribe. Embedded graph mode is single-node; see the full
guide at https://fab679.github.io/datastreamdb/embedding/queries/.
Build and test
uv venv .venv
uv pip install --python .venv/bin/python maturin pytest
.venv/bin/maturin develop
.venv/bin/pytest -q
Build a release wheel with .venv/bin/maturin build --release. The extension
uses abi3-py310, so one wheel covers Python 3.10 and newer.
Metadata
Release files for datastreamdb 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| datastreamdb-0.2.0.tar.gz | 1.1 MB | Without provenance | Details for datastreamdb-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| datastreamdb-0.2.0-cp310-abi3-manylinux_2_34_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.34+ x86-64 | Details for datastreamdb-0.2.0-cp310-abi3-manylinux_2_34_x86_64.whl |
Total release size: 6.8 MB
Release files / datastreamdb-0.2.0.tar.gz
| Download URL | datastreamdb-0.2.0.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
46c7cd2616e92421deb50ea4713549b8f9948d9cfd3bb3983c607ff540078eae
|
|
BLAKE2b-256 checksum How to use checksums |
f00c46cfae8e735d13cd5ef5d8a7131f7dad2c8b2850f4e1ad97ae5e1bdeec5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.16.0
|
Release files / datastreamdb-0.2.0-cp310-abi3-manylinux_2_34_x86_64.whl
| Download URL | datastreamdb-0.2.0-cp310-abi3-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.10 Linux glibc 2.34+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
0370a90d282f949e21406de8b49344ea6840a88d679c245dd9dd29faefb7220f
|
|
BLAKE2b-256 checksum How to use checksums |
75d077e439bba46ad84392c3eacbcc34fcf4b1c8e326cf77839f5b1ad21decff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.16.0
|
Security for datastreamdb 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.
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.