This release is a pre-release and may not be stable for production use.
Python bindings for Kerno: an embedded, local-first database of units (typed records), their revisions (every change is kept), the relations between them, and queries over all three. It runs inside your process and keeps its data in a directory on disk. There is no server.
The package is kernodb; the module you import is kerno.
Alpha (1.0.0a2). It does not open databases written by 1.0.0a1 (see Upgrading), and the keyword index is opt-in per type. The on-disk format is frozen, the API is not. Expect breaking changes between alpha releases. See the changelog.
pip install --pre kernodb # --pre: only alpha versions exist so far Wheels are published for CPython 3.9+ (one abi3 wheel per platform) on Linux x86_64 and aarch64 (glibc; musl from the next release), macOS x86_64 and arm64, and Windows x86_64. On any other platform pip builds from the source distribution, which needs a Rust toolchain.
Durable commits are verified on Linux (ext4, xfs) only; elsewhere the database works but that guarantee is not verified (see Durability).
import kerno with kerno.open("./memory-db") as db: # creates the directory if needed note = db.store("note", "Rust has no GC") # (unit_type, payload) -> id topic = db.store("topic", b"memory") # str is stored as UTF-8, bytes as they are db.relate(note, topic, "about") # (from, to, relation_type) -> relation id print([r.to_id for r in db.related(note)]) # outgoing relations db.update(note, "Rust has no garbage collector") # a new revision; the old one is kept for rev in db.history(note, with_payload=True): # newest first print(rev.revision, rev.kind, rev.payload) print([u.id for u in db.query("note")]) # every active unit of a type Leaving the with block closes the database; without it, call db.close().
out = db.commit( [ ("store", "symbol", payload_a), # op 0 ("store", "symbol", payload_b), # op 1 ("relate", 0, 1, "calls"), # an end can be an earlier "store" of this batch ("relate", existing_id, 0, "calls"), # ... or an existing unit id ("update_if_changed", other_id, new), # writes nothing if the payload is the same ("delete_cascade", old_id), # removes its relations too ], reason="index run 42", actor="indexer", # recorded with every revision detailed=True, ) out["units"], out["relations"], out["unchanged"], out["commit_seq"] All batch ops: ("store", type, payload), ("update", id, payload), ("update_if_changed", id, payload), ("delete", id), ("delete_cascade", id), ("unrelate", relation_id), ("relate", from, to, type), ("relate_unique", from, to, type), ("archive", id), ("unarchive", id), ("restore", id, revision).
db.define_schema("user", [ {"name": "email", "type": "text", "required": True, "unique": True}, # unique implies indexed {"name": "age", "type": "int", "indexed": True}, ]) uid = db.store_document("user", {"email": "a@example.com", "age": 31}) db.find("user", "email", "a@example.com") # -> [Unit] db.read_document(uid) # -> {"email": ..., "age": 31} db.execute("FIND user AS u WHERE u.age > 30") # the query language: {"aliases", "rows"} Field types: bool, int, float, text, bytes. A type has one schema, defined once. Indexes can be added later with create_index. The query language is described in docs/query-language.md.
Range lookups and query plans work on the same indexed fields:
db.find_range("user", "age", 18, 65) # both ends included; None leaves an end open db.find_range("user", "age", low=65) # age >= 65, ordered by age; `limit=` caps it db.explain("FIND user AS u WHERE u.age > 30") # how `execute` would run it, without running it # {"candidates": [{"access": "type_scan", ...}, {"access": "field_index", "field": "age", "cost": ...}], # "chosen": 1, "joins": [], ...} Search by keyword, vector and relations db.set_fulltext("note", True) # keyword (BM25) search finds only these types hits = db.hybrid_search( "garbage collector", # keyword signal vector=query_vec, vectors={uid: vec, ...}, # vector signal: your vectors, searched exactly seeds=[topic_id], # relation signal: units near these seeds ) hits[0].id, hits[0].score # best first; score = sum of the signal scores hits[0].keyword_score, hits[0].vector_score, hits[0].relation_score # None: the signal missed it Kerno does not store vectors: you pass the {unit id: vector} dict you keep in step with your units, as in the Rust API. Signals are fused by weighted reciprocal rank fusion; each adds weight / (rrf_k + rank). Only active units are hits. Types you did not enable with set_fulltext never match the keyword signal.
seq = db.last_commit_seq() db.update_document(uid, {"email": "a@example.com", "age": 32}) db.read_as_of(uid, seq).payload # the payload before the update (raw document bytes) db.history(uid, limit=10) # newest first; [] for an unknown id # Page through a long history: [from_revision, to_revision), newest first or order="asc" page = db.history(uid, limit=50) older = db.history(uid, limit=50, to_revision=page[-1].revision) diff = db.compare(uid, 1, 3) # both revisions with payloads: diff.a, diff.b, diff.same_content db.read(uid).oldest_revision # the oldest revision still kept; asking for an older one # raises PrunedError Archived and deleted units stay out of query() unless you ask: db.query("note", lifecycle="archived") (or "deleted", or "all"). A deleted unit comes back with payload=None; read its history to see what it held. find and find_range see only active units.
report = db.verify() report["clean"] # False if anything is wrong report["findings"] # what is wrong (ids and counts, never content) Damage in the storage files (a block that fails its checksum) is reported as report["storage_error"]. Reads that touch a damaged block raise kerno.CorruptionError and never return wrong data.
Type stubs ship with the package (py.typed).
Retention (dropping old revisions) is not configurable from Python. The Rust Config that open fills has no retention setting: a policy is applied by calling run_retention on the units layer, and that call has no Python binding. A database pruned by another tool (the Rust API) keeps working here. Before reading an old revision, compare it with db.read(id).oldest_revision, or catch PrunedError. A unit that was never pruned has oldest_revision == 1.
Engine failures raise kerno.KernoError or one of its subclasses:
A malformed id or direction, or a call on a closed database, raises ValueError.
These numbers are from one Linux machine (ext4), with every commit synced to disk, comparing Kerno 1.0.0a2 to SQLite in WAL mode with synchronous=FULL storing the same data (with a revision table). The full method is in docs/testing/python-vs-sqlite.md.
kerno.open asks for synchronous commits: when a commit returns, it is on stable storage. That guarantee is verified on Linux (ext4, xfs) only. On other platforms the database opens and works without that verification. In our tests, killing the process with kill -9 in the middle of a stream of commits never lost an acknowledged commit and never left half a batch.
One process holds a database directory at a time (a second open raises LockedError, also for read_only=True). Inside the process, a Database can be shared between threads. Calls release the GIL while they touch disk, any number of readers run while one writer commits, and a read never sees half of a change set.
1.0.0-alpha.2 does not open a database written by alpha.1. Opening one fails with an error whose message says the database's layer_version predates the format of this build and to export and import it. Nothing in the directory changes. To carry it over, export it with the alpha.1 command-line tool and import it with the alpha.2 one:
kerno old-db export old.kexp # kerno CLI of 1.0.0-alpha.1 kerno import old.kexp new-db # kerno CLI of 1.0.0-alpha.2 Then turn on the keyword index of every type you search by text (it is off by default in alpha.2), and define again the schemas and indexes: an export holds neither.
cd bindings/python python3 -m venv .venv && . .venv/bin/activate pip install maturin pytest maturin develop --release pytest The crate is excluded from the cargo workspace (it carries its own Cargo.lock and is built by maturin). Check it on its own with cargo clippy --all-targets -- -D warnings.
All 8 files in this release have provenance metadata.
MIT OR Apache-2.0 View SPDX License List
database embedded memory ai storage
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
All 8 files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Nov 22, 2026 8 release files Full provenance
Nov 21, 2026 8 release files Full provenance
Nov 20, 2026 6 release files Full provenance




