Skip to main content

Python bindings for Typra, a typed embedded database.

Project description

typra (Python)

CI PyPI

Official CPython bindings for Typra (PyO3 native extension): a typed, embedded database with a Rust core.

Status (v0.5.x)

You get a durable schema catalog and record insert/get (v1 encoding) 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
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.5.0,<0.6"

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

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 (all fields required).
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 (v1)

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)

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, 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.5.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typra-0.5.1.tar.gz (52.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

typra-0.5.1-cp39-abi3-win_arm64.whl (251.4 kB view details)

Uploaded CPython 3.9+Windows ARM64

typra-0.5.1-cp39-abi3-win_amd64.whl (263.3 kB view details)

Uploaded CPython 3.9+Windows x86-64

typra-0.5.1-cp39-abi3-musllinux_1_2_x86_64.whl (372.5 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

typra-0.5.1-cp39-abi3-musllinux_1_2_aarch64.whl (359.9 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

typra-0.5.1-cp39-abi3-manylinux_2_28_aarch64.whl (408.5 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

typra-0.5.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (416.1 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

typra-0.5.1-cp39-abi3-macosx_11_0_arm64.whl (350.9 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

typra-0.5.1-cp39-abi3-macosx_10_12_x86_64.whl (371.7 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file typra-0.5.1.tar.gz.

File metadata

  • Download URL: typra-0.5.1.tar.gz
  • Upload date:
  • Size: 52.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for typra-0.5.1.tar.gz
Algorithm Hash digest
SHA256 1a5654e6c964b917913b1c78e2d81a82cdf4c2343c23d9d02237a72658bae839
MD5 e81d67b6f6e9b1b02f32d079d99d58d2
BLAKE2b-256 90a1f9b7c845d46a3330348eda32fc61dc17de229ecf670abfd1d2b03a5bd0e5

See more details on using hashes here.

File details

Details for the file typra-0.5.1-cp39-abi3-win_arm64.whl.

File metadata

  • Download URL: typra-0.5.1-cp39-abi3-win_arm64.whl
  • Upload date:
  • Size: 251.4 kB
  • Tags: CPython 3.9+, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for typra-0.5.1-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 f1d81be5d5a029d5d0d55c0a621f524532e594d2cff5fd592fe26e6b938abcb0
MD5 aea4269c469e43adabe97e418dec0cb3
BLAKE2b-256 892d11fc4d9de0f2a8770bc5adc6d6db706d4a263036b1d3a7242c65bf270623

See more details on using hashes here.

File details

Details for the file typra-0.5.1-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: typra-0.5.1-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 263.3 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

Hashes for typra-0.5.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 92c35780d777b852075eb215f32103cdd97bec3ef020ae8e107d5e9531ab9fb5
MD5 d544120f9580f76b7d3a56bd210a39e3
BLAKE2b-256 fd418eeac74d741f7ab4d0677bd248e5418fc151693f04753bcd541b9cebd1c0

See more details on using hashes here.

File details

Details for the file typra-0.5.1-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: typra-0.5.1-cp39-abi3-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 372.5 kB
  • 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

Hashes for typra-0.5.1-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a17653141c4a70fac0c48cb8ba67670b2f049aa80d82489dd6f80ac851ee2f98
MD5 45809fe2daba7e732089523982a94fdc
BLAKE2b-256 d4d3b70a77124289ed1b551601d38a75c36116be57fa1cd2df2ce34f10b7d3d0

See more details on using hashes here.

File details

Details for the file typra-0.5.1-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for typra-0.5.1-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a2c52dacfaa68055ed5c768b9b1d1210d9bcc2bf6af8cb5e3dad1e8076d078c7
MD5 07dfa1e0650af448d12e90891b2bdcc7
BLAKE2b-256 0a37ca2eb8b701330f15796e65368f7d3a8f5c53ee30f9d5629f954ce4377b84

See more details on using hashes here.

File details

Details for the file typra-0.5.1-cp39-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for typra-0.5.1-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 75bea8a9e3271de05225dad0436d54adc46c490e59f6bca7a51baa7248fb5f38
MD5 e9dce6c2f0ae3fbfda17240e335b5f14
BLAKE2b-256 5641578334e9f4e9540a519e63a597656cfe790e298d0e329c1a584709ebb968

See more details on using hashes here.

File details

Details for the file typra-0.5.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for typra-0.5.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b71176771927b619a1b5926838d5665592fe3ab14b37ac5e585189b743dca65c
MD5 ed96a0667d5f14f97f1675638a59148b
BLAKE2b-256 4a4704dc40d5ea35cdf7692a44ffb640f3729037af786b2fc5ec8d9ee5c0f30c

See more details on using hashes here.

File details

Details for the file typra-0.5.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: typra-0.5.1-cp39-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 350.9 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

Hashes for typra-0.5.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f8b647e960d9e24a09dc40a35ce5a04e38828bb4c8f6631b95d94581834dcd6b
MD5 0b6f1c896a59b7aba669e26c1ae757db
BLAKE2b-256 dea97ca632ec74f1e57fa43b1299ffc48ea4ff91de4bef145bd716226105a2e2

See more details on using hashes here.

File details

Details for the file typra-0.5.1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for typra-0.5.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 10adff6f88bc696bb8cc89ec59c329808253f488126fff85eaea93f961ac2523
MD5 44d7347bd0682f817da9a4f746f97a8f
BLAKE2b-256 70ae8fd0b5aa9fd6270a8bfba2ac4448d0c0fe21301959f9530a1ebd1579def4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page