Python bindings for Typra, a typed embedded database.
Project description
typra (Python)
Official CPython bindings for Typra (PyO3 native extension): a typed, embedded database with a Rust core.
Status (v0.6.x)
You get a durable schema catalog, validation, nested row values (record v2 on insert; v1 segments still replay), and constraints in a single .typra file, plus in-memory databases and snapshot bytes. SQL / rich queries are still planned—see the roadmap.
| Resource | Link |
|---|---|
| Repository | github.com/eddiethedean/typra |
| Rust crates | typra on crates.io |
| Full Python guide | docs/guide_python.md |
| Getting started | docs/guide_getting_started.md |
| Migrating 0.4 → 0.5 | docs/migration_0.4_to_0.5.md |
| Migrating 0.5 → 0.6 | docs/migration_0.5_to_0.6.md |
| Rust module layout | docs/03_rust_crate_and_module_layout.md |
| Changelog | CHANGELOG.md |
Requirements
- CPython 3.9+
- Wheels use the stable ABI (
cp39-abi3): one wheel per platform, compatible with Python 3.9+ on that platform.
Install
pip install "typra>=0.6.0,<0.7"
Pin the minor range you test against; pre-1.0 releases may still change APIs or the on-disk format between minors.
Quick start
import typra
db = typra.Database.open_in_memory()
cid, ver = db.register_collection(
"books",
'[{"path": ["title"], "type": "string"}]',
"title",
)
print("registered", cid, ver)
db.insert("books", {"title": "Typra"})
print(db.get("books", "Typra"))
print(typra.__version__)
Output (the version line matches the installed wheel):
registered 1 1
{'title': 'Typra'}
0.6.0
On disk, use Database.open("app.typra") instead; registrations are persisted across process restarts for that path.
API overview
| Member | Description |
|---|---|
typra.__version__ |
Package version (matches the Rust workspace release). |
Database.open(path: str) |
Create or open a database file. Raises OSError if the path cannot be opened (e.g. missing parent directory, path is a directory). |
db.path() -> str |
Path used to open the database. |
db.register_collection(name, fields_json, primary_field) -> tuple[int, int] |
Register a new collection (schema version 1). primary_field is the top-level field name for the PK. Returns (collection_id, schema_version). Names are trimmed; duplicates or bad fields_json raise ValueError. |
db.insert(collection_name, row: dict) -> None |
Insert or replace the latest row (required fields + optional keys per schema). |
db.get(collection_name, pk) -> dict | None |
Latest row or missing. |
Database.open_in_memory() / Database.open_snapshot_bytes(data) / db.snapshot_bytes() |
In-memory DB and byte snapshots. |
db.collection_names() -> list[str] |
All registered names, sorted alphabetically. |
For behavior details (errors, edge cases, development), see the Python user guide.
fields_json (schema descriptor)
register_collection expects fields_json to be a JSON array of objects. Each object describes one field:
path: JSON array of strings (path segments), e.g.["profile", "name"].type: either a primitive name or a composite object.
Primitives: "bool", "int64", "uint64", "float64", "string", "bytes", "uuid", "timestamp".
Composites:
- Optional:
{"optional": <inner>} - List:
{"list": <inner>} - Object:
{"object": [ … same shape as top-level field objects … ]} - Enum:
{"enum": ["a", "b"]}(variants must be strings) constraints(optional): JSON array of constraint objects, e.g.{"min_i64": 0},{"max_length": 100},{"email": true},{"regex": "^[a-z]+$"}.
Example (nested)
db.register_collection(
"items",
'[{"path": ["x"], "type": {"optional": "int64"}}]',
"x",
)
Example (multiple fields)
schema = """[
{"path": ["title"], "type": "string"},
{"path": ["year"], "type": "int64"},
{"path": ["tags"], "type": {"list": "string"}}
]"""
db.register_collection("books", schema, "title")
Exceptions
ValueError: invalid JSON, wrong shape, unknown type, invalid collection name, duplicate collection name, validation failures, or format/schema errors from the engine when registering.OSError: I/O failures when opening the database file.RuntimeError: reserved for engine “not implemented” paths (unexpected for supported 0.6.x calls).
Building from source
You need Rust, Python 3.9+, and maturin. From the repo’s python/typra directory:
maturin develop --release
pytest -q
From the repository root, make check-full runs Rust + Python checks, tests, and make verify-doc-examples (validates documented command output). See also python/README.md (workspace layout for contributors).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file typra-0.6.0.tar.gz.
File metadata
- Download URL: typra-0.6.0.tar.gz
- Upload date:
- Size: 63.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c086eb163d0dfa9fe5cf2ce949e2fd6eac65439f35d5e7a6bb79f92db134c4f0
|
|
| MD5 |
17ddea056349576ef4f32181fba4d50a
|
|
| BLAKE2b-256 |
8c52714162ac0c890d555024e3726e9b37ec4fbc83b7aa3eb39eb46eeb359991
|
File details
Details for the file typra-0.6.0-cp39-abi3-win_arm64.whl.
File metadata
- Download URL: typra-0.6.0-cp39-abi3-win_arm64.whl
- Upload date:
- Size: 827.1 kB
- Tags: CPython 3.9+, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39e2fc429343f743d1a86bdab9c4626967f419d2838f2075d51ffa3b2d6bbd54
|
|
| MD5 |
ff482cc37970ae6344039a515908e669
|
|
| BLAKE2b-256 |
b0a492deff9ff8bd6e3d764c0629b5db15f7be06e7af7c17145d84a6273be5d1
|
File details
Details for the file typra-0.6.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: typra-0.6.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 885.2 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
027d832a43a5b2ac95cc17a8c09f8d3acea1f2f8e415d784ce5811ebe7512866
|
|
| MD5 |
2730eb456a6e50c226381c8e5fcc8b97
|
|
| BLAKE2b-256 |
1b3309574f8a0f2c80b7cd9b0d1d1b05ae635f8d8134faa3d70e60a1bbdb8d2f
|
File details
Details for the file typra-0.6.0-cp39-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: typra-0.6.0-cp39-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7736ddbd5d55be9d0ffd8935591a34a413d276578a5321f6051ea3baf6c1e063
|
|
| MD5 |
61aaea05c80105c9a89a9f9108c44023
|
|
| BLAKE2b-256 |
701eb7f55ead1bd142c1cb8ed604a4514bd07906530140be1e49b9c42175c97b
|
File details
Details for the file typra-0.6.0-cp39-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: typra-0.6.0-cp39-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 928.5 kB
- Tags: CPython 3.9+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
985986f04d73279a9630c28418724e6c13abc8ddf7bfcc45af583fa9c2284cb0
|
|
| MD5 |
0161af46494cc58694c1f0a6d048afd2
|
|
| BLAKE2b-256 |
f62260b89020fbe75ddafe3f02eb34734675321bd30a03ad5dfd9d46d4f08779
|
File details
Details for the file typra-0.6.0-cp39-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: typra-0.6.0-cp39-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0415345b4cbdc53d88951f1fcc4a3479041ef70b7adbba35f7db6dd02c82bb8
|
|
| MD5 |
8c705731ab7a8b3daef13c0a867573ca
|
|
| BLAKE2b-256 |
8af0caf9d3ce4e89764577b9b58bd9b7a164f2296224229b9a4e9e25fe57bb4b
|
File details
Details for the file typra-0.6.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: typra-0.6.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0ab1c8ab7537ce0782efe0d29231113935061624ab4f119486910e8a14c3027
|
|
| MD5 |
1d1ae02789eeec8a3de6c13464cb1457
|
|
| BLAKE2b-256 |
45f1d530812d53ea21ee629fd693818fe053baae8da8868f36c91dc0db39db7e
|
File details
Details for the file typra-0.6.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: typra-0.6.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 964.0 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10b7ae031f14ef4e4cd5d7f7cec870d18216c6589c2c1ab89e552628c7167435
|
|
| MD5 |
761764a4a0b07c1aa9515b7e653be976
|
|
| BLAKE2b-256 |
ffe1bb14afda4d04a94d00875537ad20d1bfecdfe73b02fd9cdee2093bc42055
|
File details
Details for the file typra-0.6.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: typra-0.6.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac0467d2e91b6defaba62995579caefc25614fbb500bc847940f8092a09dbe7f
|
|
| MD5 |
9d1e91fb2d871eec5e0f65ac006e14c9
|
|
| BLAKE2b-256 |
97ef57c9f33ec52bb796399961c94d4afac8b86be5d04a0fdbb46374d6920dfe
|