datastreamdb
Python bindings for DataStreamDB — embedded graph database with DQL and GraphQL in-process. 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.1"
db = Instance("{}") # isolated in-memory instance
db.dql_alter("""
name: string @index(exact) .
friend: [uid] @reverse .
type Person {
name
friend
}
""")
db.dql_mutate("""
{ set {
_:ada <name> "Ada" .
_:bob <name> "Bob" .
_:ada <friend> _:bob .
} }
""")
result = json.loads(db.dql_query("""
{ people(func: eq(name, "Ada")) { name friend { name } } }
"""))
print(result)
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.
GraphQL
db.set_graphql_schema("""
type Post {
id: ID!
title: String @search(by: [term])
author: Author @hasInverse(field: posts)
}
type Author {
id: ID!
name: String @id @search(by: [hash])
posts: [Post]
}
""")
response = json.loads(db.graphql("""
mutation {
addPost(input: [{title: "Hello", author: {name: "Ann"}}]) {
post { id title author { name } }
numUids
}
}
"""))
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/.
API
| Method | Description |
|---|---|
Instance(config_json) |
Open a memory or persistent instance. |
id() |
Unique instance id. |
backend() |
"memory" or "fjall". |
dql_alter(schema) |
Apply additive/updating DQL schema. |
dql_mutate(mutation) |
Apply a DQL mutation; returns assigned uids as JSON. |
dql_query(query) |
Run a DQL query; returns JSON text. |
set_graphql_schema(sdl) |
Install/replace the GraphQL schema. |
graphql(query, variables_json=None, operation=None, headers_json=None) |
Run GraphQL; returns JSON text. |
graphql_subscribe(query, variables_json=None, headers_json=None, poll_ms=100) |
Create a poll subscription. |
graphql_next(id, wait_ms=0) |
Poll a subscription. |
graphql_unsubscribe(id) |
Cancel a subscription. |
The low-level put, get, execute (scan/batch), and flush methods remain
available for raw storage, but graph applications should use DQL and GraphQL.
See https://fab679.github.io/datastreamdb/embedding/key-value/.
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.1
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.1.tar.gz | 1.1 MB | Without provenance | Details for datastreamdb-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| datastreamdb-0.2.1-cp310-abi3-manylinux_2_34_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.34+ x86-64 | Details for datastreamdb-0.2.1-cp310-abi3-manylinux_2_34_x86_64.whl |
Total release size: 6.8 MB
Release files / datastreamdb-0.2.1.tar.gz
| Download URL | datastreamdb-0.2.1.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b64b7bacc131c700041aa2d12f0f40cd739e8a0ba91d013e18df66cf6bf963da
|
|
BLAKE2b-256 checksum How to use checksums |
23de7fb7c57702f9b8a76c229cb94e58e332f3c3a314482866a84ca7268cc30f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.16.0
|
Release files / datastreamdb-0.2.1-cp310-abi3-manylinux_2_34_x86_64.whl
| Download URL | datastreamdb-0.2.1-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 |
6c784e2c84b6386931d08157dac077bbce4ff685ef762c4f017ce40793c69dd9
|
|
BLAKE2b-256 checksum How to use checksums |
a799c1537aabdd688ba8b5aa2e5c931ebeb56c55498ba568aa0c22a743d5f199
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.16.0
|
Security for datastreamdb 0.2.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.