Skip to main content

Python bindings for Typra, a typed embedded database.

Project description

typra (Python)

CI PyPI

Typra is a typed, embedded database with a Rust core. This package is the official CPython bindings (PyO3, native extension).

In 0.4.x you get a durable schema catalog in a single .typra file: open a database, register collections with a JSON field schema (fields_json), and list names. Record insert/get and queries are not available yet; they are planned for later releases (roadmap).

Repository github.com/eddiethedean/typra
Full Python guide docs/guide_python.md
Changelog CHANGELOG.md

Requirements

  • CPython 3.9+
  • Wheels use the stable ABI (cp39-abi3): one wheel per platform, compatible with Python 3.9 and newer on that platform.

Install

pip install "typra>=0.4.0,<0.5"

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("app.typra")
cid, ver = db.register_collection(
    "books",
    '[{"path": ["title"], "type": "string"}]',
)
assert cid == 1 and ver == 1
assert db.collection_names() == ["books"]

Registrations are persisted: reopening the same path shows the same catalog.

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) -> tuple[int, int] Register a new collection (schema version 1). Returns (collection_id, schema_version). Names are trimmed; duplicates or bad fields_json raise ValueError.
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"}}]',
)

Example (multiple fields)

schema = """[
  {"path": ["title"], "type": "string"},
  {"path": ["year"], "type": "int64"},
  {"path": ["tags"], "type": {"list": "string"}}
]"""
db.register_collection("books", schema)

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

Or from the repository root, run make check-full (Rust + Python checks and tests). See also python/README.md.

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.4.0.tar.gz (33.0 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.4.0-cp39-abi3-win_arm64.whl (198.3 kB view details)

Uploaded CPython 3.9+Windows ARM64

typra-0.4.0-cp39-abi3-win_amd64.whl (206.6 kB view details)

Uploaded CPython 3.9+Windows x86-64

typra-0.4.0-cp39-abi3-musllinux_1_2_x86_64.whl (317.4 kB view details)

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

typra-0.4.0-cp39-abi3-musllinux_1_2_aarch64.whl (305.2 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

typra-0.4.0-cp39-abi3-manylinux_2_28_aarch64.whl (346.6 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

typra-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (353.0 kB view details)

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

typra-0.4.0-cp39-abi3-macosx_11_0_arm64.whl (291.5 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

typra-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl (309.8 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for typra-0.4.0.tar.gz
Algorithm Hash digest
SHA256 0d3c67619785f010f56679341576d53233dffc4afa4a77a09adb4b08e474c0e7
MD5 978487789fd9889b2b43f18c0b33a4d4
BLAKE2b-256 fd4fe4aca1063011b358b24f268893408b821197d5b6ecc38e5b513a804c309c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typra-0.4.0-cp39-abi3-win_arm64.whl
  • Upload date:
  • Size: 198.3 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.4.0-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 487a842167a40963dccd3aec521e423c63cbc2ccc4bab49be232a1bfee20a492
MD5 87c12fbcbbfa92c6f6542a988d8748ef
BLAKE2b-256 6889ace532e3b5475317abc3f46398713394bd0516044a16d6fb9a3ed55f5e87

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typra-0.4.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 206.6 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.4.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9b13359e6238681ef0513cd15a6de6ebc3d8579752f3238c6e2e3b8e1384ebd8
MD5 0b602cdd7226cc9a35b157e7c9ea8f31
BLAKE2b-256 947099aee13c0f54d7eec67f1dd6fcbf3e311bddbb395e943378b8f6a04ffa9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typra-0.4.0-cp39-abi3-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 317.4 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.4.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b5c37a6c2a48b7a158d3b682b0cf77c4f66bb12db4ccd2bb1239a29c94a3beb7
MD5 8aa27fa932692e9532a53176f6898b1f
BLAKE2b-256 73137979f0199ee129b0bc53732bdc607fc10dafcfe278d74bd8e99cd6d6e242

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typra-0.4.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8f5f3f175a576d3d0b4aa32c7ef55cf9354cec30ed2d25ecfef4a5de4ad06bda
MD5 46dea925c2078cb4e9a914d96586dbdc
BLAKE2b-256 d35eb506a249ec6fb297e9130497dc0857111606b1ea592a548a478b932f58a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typra-0.4.0-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e18bd3faa084ce86d15ead3c3285a0c93ab1dff53f9f0e3ad4c40a2b014aeb1b
MD5 7dd3ccbff6d73e37ce9ad1021763b258
BLAKE2b-256 5be8eb46306a498bf1921801b8e06a618df10815f090cb1f78f7732c6e24df7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typra-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 af34a44f977cb95d0ecd90b6a07b16ed3b690fa12050414199c66c87de6a36ee
MD5 1be23398afa87171537294db3970a707
BLAKE2b-256 a72cd81923c2a22c90da07c39115c34758364b7ec960b5af74ae766e08152336

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typra-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 291.5 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.4.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab3ef0e41d5b48080a724cef34cbb3f8b7cd811642a2d662aa9ffe85d9372719
MD5 a938d728a2730cf15c258ecffb77a2e2
BLAKE2b-256 650ff0f2ba1ea91b2caa4330336662e1615ba81d9aba6b20b6edc64a6bd3acac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typra-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4d9f701dd8673acdeffc1d2e5f809414224ee8542cb2d51d59a3d5b50433dfdf
MD5 94191cd8bd74f44feda5c6ede08afa8e
BLAKE2b-256 fefb94e3d2ad3dfafce9f762562c99cdca428a73ef70e80450e2f77efac1d9db

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