Skip to main content

SQLite for event-sourced state — Python bindings for salamander-db.

Project description

salamander-db (Python)

Native Python bindings for salamander-dbSQLite for event-sourced state. This is a compiled extension (via PyO3 + maturin), so it embeds the engine in your process exactly like Python's built-in sqlite3 module wraps libsqlite3: you open one handle and reuse it. No server, no subprocess.

The binding is a translation layer over the safe, non-generic Rust Engine. Database ownership and cross-thread sequencing live in the core; Python does not contain storage, replay, branching, or projection algorithms.

import salamander

db = salamander.open("./mem", commit_every_count=8)   # one in-process handle
db.append("session-1", {"kind": "user_msg", "text": "hi"})
db.append("session-1", {"kind": "tool_call", "tool": "grep", "args": {"q": "500"}})
db.commit()

for ev in db.replay("session-1"):
    print(ev["offset"], ev["body"])          # -> plain dicts, nested fields intact

The open handle owns the single-writer lock, any registered views, and the group-commit state — which is why it must be long-lived and in-process, not re-created per call.

Build it

Requires a Rust toolchain and Python ≥ 3.9.

python -m venv .venv && source .venv/bin/activate    # Windows: .venv\Scripts\activate
pip install maturin pytest
maturin develop -m salamander-py/Cargo.toml          # compiles + installs into the venv
python examples/py/quickstart.py
python -m pytest examples/py/test_roundtrip.py -v

On a very new Python that the pinned PyO3 doesn't recognize yet, prefix the build with PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 (the abi3 stable ABI is forward-compatible).

API

Python Engine
salamander.open(path, commit_every_bytes=, commit_every_count=, commit_every_millis=) JsonDb::open_with_policy
db.append(namespace, event: dict) -> int append (payload = JSON)
db.append_branch(branch, namespace, event) -> int append to an engine branch
db.commit() -> int commit (fsync)
db.head() -> int head
db.uncommitted_count() -> int group-commit tally
db.replay(namespace, start=0, end=None) -> list[dict] replay (literal)
db.register_view(name, key, indexes={}, where_field=, where_value=) register an IndexedView
db.view(name) -> View typed query handle
db.deregister_view(name) -> bool deregister
db.fork(namespace, at) -> str create branch (returns branch name)
db.history(namespace) -> list[dict] default-branch replay
db.branch_history(branch, namespace) -> list[dict] inherited branch replay

View handles support .get(key), .by(index, key), .range(lo, hi), .prefix(p), .len().

Payloads are any JSON-able Python value (dict/list/str/int/float/ bool/None), converted to/from serde_json::Value at the boundary. Views are declared by field name (primary key, indexes mapping name→field, an optional where_field/where_value filter) — no per-event Python callback crosses the FFI boundary.

A LangGraph checkpointer that survives process restarts ships in examples/py/; an MCP server is on the roadmap. Branch lifecycle and ancestry use the same engine catalog as Rust:

ancestry = db.branch_ancestry(branch_name)  # root-first metadata dictionaries
archived = db.archive_branch(branch_name)  # history remains readable

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

salamander_db-0.1.0.tar.gz (121.6 kB view details)

Uploaded Source

Built Distributions

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

salamander_db-0.1.0-cp39-abi3-win_amd64.whl (686.3 kB view details)

Uploaded CPython 3.9+Windows x86-64

salamander_db-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (857.2 kB view details)

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

salamander_db-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (847.5 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

salamander_db-0.1.0-cp39-abi3-macosx_11_0_arm64.whl (761.4 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

salamander_db-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl (809.7 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file salamander_db-0.1.0.tar.gz.

File metadata

  • Download URL: salamander_db-0.1.0.tar.gz
  • Upload date:
  • Size: 121.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for salamander_db-0.1.0.tar.gz
Algorithm Hash digest
SHA256 66aa9e41a574d9df15fdab2b71b31ec2ad62a43cea95a17e405334b34c19f302
MD5 87fd9d566e51e9447f5c5f817d88b99d
BLAKE2b-256 fcba569318be4f17e5ae406dab4a40978f05337c7b19eb5a8ee2ef95e48a1310

See more details on using hashes here.

Provenance

The following attestation bundles were made for salamander_db-0.1.0.tar.gz:

Publisher: release-python.yml on rdelprete/salamander-db

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file salamander_db-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: salamander_db-0.1.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 686.3 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for salamander_db-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 833b2f59780d55e495b828fc84ca3d2120c0b2ddc11c32f56597e7fc3d8c2a31
MD5 fae6fbae265765a0caa6184d98eb4f3c
BLAKE2b-256 db0563611bdcc834bfb3fb8522f75fc6a801d449a61037fc59af949cfa6943a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for salamander_db-0.1.0-cp39-abi3-win_amd64.whl:

Publisher: release-python.yml on rdelprete/salamander-db

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file salamander_db-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for salamander_db-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1e68bbd9d3978d01cb5c42ca4be4762e13853fecc76ab6f9cb6289f75d67b043
MD5 5bd4dcbbe840b82232b485ecd556fc19
BLAKE2b-256 4aad157adfed70d07e0fc70285fde398fca7e1f3dea5dca6e96fdd78aa140985

See more details on using hashes here.

Provenance

The following attestation bundles were made for salamander_db-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-python.yml on rdelprete/salamander-db

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file salamander_db-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for salamander_db-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b58df1ad0fa8424775ba1ca5749070cf875c2c4766b48c5e640c6848c52ca238
MD5 2a0bc1871596bffe0cee06b01660ddbf
BLAKE2b-256 b46c8165d457de63b8b2f0101f80f0158f979e2da3388fb489c74b42170fc5c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for salamander_db-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-python.yml on rdelprete/salamander-db

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file salamander_db-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for salamander_db-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c9304d2b7b7f7a14c46a8d824447e8702bc98a2f68472ead7c4be83c8a52466c
MD5 67e20451f4a044dc5a990f491ceab750
BLAKE2b-256 7f0554086ce20d3bb9f8c07d008aa9766fc044839617f4fc9a1b7c02c7a5850b

See more details on using hashes here.

Provenance

The following attestation bundles were made for salamander_db-0.1.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release-python.yml on rdelprete/salamander-db

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file salamander_db-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for salamander_db-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8487ff98fd2cbdd14b621b1b08d303301dbfcbd24de4171a4f72118f40f67d7b
MD5 74fc302e18530f7c0e0637d8de585b6a
BLAKE2b-256 6efb42ae4d27c1f96e61ceb3fe67461fc5cf9da4b38054a8794d9a59f4ac5f01

See more details on using hashes here.

Provenance

The following attestation bundles were made for salamander_db-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release-python.yml on rdelprete/salamander-db

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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