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
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.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 (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.0.tar.gz (47.2 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.0-cp39-abi3-win_arm64.whl (255.5 kB view details)

Uploaded CPython 3.9+Windows ARM64

typra-0.5.0-cp39-abi3-win_amd64.whl (264.8 kB view details)

Uploaded CPython 3.9+Windows x86-64

typra-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl (374.8 kB view details)

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

typra-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl (357.0 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

typra-0.5.0-cp39-abi3-manylinux_2_28_aarch64.whl (407.7 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

typra-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (415.9 kB view details)

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

typra-0.5.0-cp39-abi3-macosx_11_0_arm64.whl (349.0 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

typra-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl (370.5 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: typra-0.5.0.tar.gz
  • Upload date:
  • Size: 47.2 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.0.tar.gz
Algorithm Hash digest
SHA256 ca2084f6dfbd2e1fd888e51bcb70e79fa63d9bfc7e9393c7bdeea634d93bd5c2
MD5 401a5b9b9f3496ceba2e1c86ab92d8ac
BLAKE2b-256 c35fe9872e27ee47ec53b046a6c9cba2a06b519c495144f3009748ce9bfbd94f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typra-0.5.0-cp39-abi3-win_arm64.whl
  • Upload date:
  • Size: 255.5 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.0-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 c963358405047214953b6e3d32083970913b0fdcab7513cab6f6dac87b4c8767
MD5 8b7962e1b0025118cad6ebf9506ba2e9
BLAKE2b-256 59ace7b45b4a2548e234a1c9a565c4b15ec3e4a577356fcece047ff905e42668

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typra-0.5.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 264.8 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.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8b7969cd8fa2dc2dd2b540efde423260ff92d374fd660471dda801c2aca96636
MD5 dea599a2b31891eb11bab2d19e3a5acd
BLAKE2b-256 e4fede58fdc2949715806de7660e99df5b303dc4bec3c5130b2309b7979ee311

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typra-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 374.8 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.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 febcfb5f8697108920dab9ee2afbf067eb7325db4be583d7bcca949c63374634
MD5 aaee686c9556e36e06f7ed26d7603f6c
BLAKE2b-256 cb5722377d34b1dc15dfa8d35e873e614da3698ae8d47b54a2cf7b546548542c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typra-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 01b93fd6d2ae414d5dbdfdb92993afe0d8cacdb5cc85cd3479e74dfecae7dec6
MD5 c1863adcae728726df340c260a0a8ac5
BLAKE2b-256 c4d1df04a547905736c4f756520b333321332d64a91d321f25530e7f43af5577

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typra-0.5.0-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 63fa4c40d6851e85299b46c670f52c4bf768842b514c4268823b06f9f987fa71
MD5 c1aca60576af9de8be7fecb88e408e68
BLAKE2b-256 8d9b4e86f45873e5ece370e78e5962079a10fb03d99478e3e3197d05be156c31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typra-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b5ecd700ae202f29ca29fcb3f5538ca1e18bb71ef7274f428129e1d2df98d26b
MD5 f516c0248543d7971e77b49c84d9199e
BLAKE2b-256 73ffd4400b453a00648e5fa267f4400c496c9cb3e0c7fee4e8f7f5388719d582

See more details on using hashes here.

File details

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

File metadata

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

Hashes for typra-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4385f3ae97a074497caacb2f4f0efde3602f367a7906a0ac51fee30f5b515775
MD5 5a0f2436096fb253eaa3bc82a6638ada
BLAKE2b-256 0c111fc22750e997b158c97a900221095119319c2e612ad5a3a360a87f528769

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typra-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1d7aff1c559a2c35006cb05c8f4f6deecc17c86e6854cf5a022377e09eb02566
MD5 0206dc82b024eb2433c453a35addf628
BLAKE2b-256 6b34d2b1f838962791c8162d581961a4f66fb5251bc04e622b039d4127e572f8

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