Skip to main content

MongrelDB logo

MongrelDB Kit

The application-facing persistence layer for MongrelDB - schema-aware query builder, migrations, relational constraints, and stable semantics across TypeScript, Rust, Python, and CLI surfaces.

crates.io npm PyPI

Packages And Tools

Surface Package / crate Install or run
TypeScript @visorcraft/mongreldb-kit npm install @visorcraft/mongreldb-kit @visorcraft/mongreldb
Rust mongreldb-kit cargo add mongreldb-kit
Python mongreldb-kit pip install mongreldb-kit
CLI mongreldb-kit-cli (mongreldb-kit binary) cargo run -p mongreldb-kit-cli -- --help

What It Provides

  • Schema helpers for typed tables, stable table/column ids, defaults, indexes, checks, unique constraints, and foreign keys. Full type set: int64, float64, bool, text, bytes (BLOB), timestamp, date, date64, time64, interval, decimal128, UUID, JSON, and array columns.
  • Synchronous TypeScript CRUD/query builder with predicates, ordering, projections, aggregates, joins, subqueries, CTEs, batch inserts, updates, and deletes.
  • Rust and Python APIs backed by the same Rust core and verified with cross-language conformance fixtures.
  • Migration runner with content-addressed checksums, stored schema catalog, table renames, and SQL views.
  • Embedded SQL surface (sql / sqlArrow / sqlRows) with recursive CTEs, window functions, CREATE TABLE AS SELECT, materialized views, multi-statement execution, and a mongreldb_fts_rank relevance-scoring UDF.
  • Storage tuning (spill thresholds, compaction zstd, result-cache sizing, index build policy), trigger config, and per-table introspection (run count, page-cache stats, memtable/cache lengths).
  • Maintenance: analyze / vacuum (compact+gc) and checkpoint() to flush, compact, and drop rotated WAL segments so recovery stays bounded (MongrelDB 0.64.18+).
  • BinarySign and full-f32 Dense ANN schema options, plus durable online create/replace index jobs with status, cancellation, resume, and wait APIs in Rust, TypeScript, and Python.
  • Non-blocking async I/O variants (putAsync / queryAsync / countAsync / …) and WriteBuffer micro-batching for high-throughput ingest (TypeScript).
  • Engine-side trigger management plus SQL-backed virtual/external table helpers.
  • Extended SQL Function helpers for JSON, date/time, aggregate, and math-style SQL calls.
  • User/role/credentials management with optional storage-layer enforcement: Argon2id-hashed catalog users, roles, GRANT/REVOKE table-level permissions, daemon HTTP Basic + Bearer auth, and opt-in require_auth credential enforcement (credentialed open/create constructors, enable_auth/disable_auth, offline recovery) - exposed through every language API, the embedded SQL surface, and the CLI (user / role / auth subcommands).
  • CLI access to page-encrypted databases. mongreldb-kit opens them with --passphrase, --passphrase-stdin, or MONGREL_PASSPHRASE on get and every other command that opens a database directory. init still creates a plaintext database.
  • Relational constraint enforcement on top of MongrelDB transactions: not-null, type/range/string validation, unique/composite unique, foreign keys, and cascade/set-null/restrict deletes.
  • Multi-process file locking, replication, and change-data-capture via the daemon.

Documentation

History retention and time-travel reads

Both the embedded KitDatabase and the daemon client RemoteDatabase expose history-retention controls:

// TypeScript
db.setHistoryRetentionEpochs(100);   // embedded: number argument
remote.setHistoryRetentionEpochs(100n); // remote: bigint argument
console.log(db.historyRetentionEpochs());     // bigint
console.log(remote.historyRetentionEpochs()); // bigint
console.log(db.earliestRetainedEpoch());      // bigint
# Python (embedded)
db.set_history_retention_epochs(100)
print(db.history_retention_epochs())  # int
print(db.earliest_retained_epoch())   # int

# Python (remote)
remote.set_history_retention_epochs(100)
print(remote.history_retention_epochs())
print(remote.earliest_retained_epoch())

Set retention before writing the data you want to time-travel back to. Embedded databases initially keep only the latest epoch. The daemon defaults to 1024 epochs unless MONGRELDB_HISTORY_RETENTION_EPOCHS overrides it. Increasing retention later cannot restore history that has already been removed. Read past snapshots with db.rowsAtEpoch('table', epoch) (embedded) or SELECT ... AS OF EPOCH <epoch> (embedded SQL and the daemon).

Quick Example

Minimal TypeScript schema and CRUD flow:

TypeScript

import {
  KitDatabase,
  Schema,
  table,
  int,
  text,
  sequenceDefault,
  unique,
  eq
} from '@visorcraft/mongreldb-kit';

const users = table('users', {
  columns: [
    int('id', { primaryKey: true, default: sequenceDefault('users_id_seq') }),
    text('email', { nullable: false }),
    text('name', { nullable: true })
  ],
  primaryKey: 'id',
  unique: [unique(['email'], { name: 'users_email_uq' })]
});

const schema = new Schema([users]);
const db = KitDatabase.openSync('./app-data', schema);

db.migrateSync(schema, [
  {
    version: 1,
    name: 'initial',
    up({ ensureTable }) {
      ensureTable(users);
    }
  }
]);

const alice = db.insertInto(users)
  .values({ email: 'alice@example.com', name: 'Alice' })
  .executeSync();

const [row] = db.selectFrom(users)
  .where(eq(users.id, alice.id))
  .executeSync();

console.log(row);
db.close();

See the language docs for complete runnable examples in TypeScript, Rust, and Python.

Development Notes

  • TypeScript requires Node.js 22+ and the native @visorcraft/mongreldb peer dependency.
  • A MongrelDB database path is a data directory, not a single database file.
  • In this mono-repo checkout, the TypeScript package loads the native addon from the sibling MongrelDB repo. Build crates/mongreldb-node there with npm run build in release mode before benchmarking; stale debug .node builds make bulk paths much slower.

Building and testing

# Rust
rtk cargo check --workspace
rtk cargo test --workspace

# TypeScript
cd packages/kit
rtk npm ci
rtk npm run build
rtk npm run check
rtk npm test

# Python
cd python/mongreldb_kit
rtk python -m venv .venv
rtk .venv/bin/pip install maturin
rtk maturin develop
rtk .venv/bin/pytest ../../python/tests ../../tests/conformance/python

# CLI
rtk cargo run -p mongreldb-kit-cli -- --help

Encrypted databases

A database created with page encryption (AES-256-GCM) does not open through the normal plaintext path. Pass the passphrase on any Kit command that opens the directory:

mongreldb-kit --passphrase "$MONGREL_PASSPHRASE" get ./store.kitdb customers 1

MONGREL_PASSPHRASE supplies the same value. --passphrase-stdin reads one line from stdin. auth disable-offline uses this flag too. With --user, the CLI opens the database through the encrypted credentialed path.

mongreldb-kit init does not encrypt. Create an encrypted database with the Rust or language create_encrypted constructor. Details are in the CLI guide.

  • Mongrel — Commercial multi-system workbench with native MongrelDB support.
  • MongrelDB Viewer — Free, open-source MongrelDB GUI and MCP server.

License

MIT OR Apache-2.0

Metadata

Release files for mongreldb-kit 0.64.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for mongreldb-kit 0.64.20
File Actions
mongreldb_kit-0.64.20-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for mongreldb_kit-0.64.20-cp310-abi3-win_amd64.whl
mongreldb_kit-0.64.20-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for mongreldb_kit-0.64.20-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
mongreldb_kit-0.64.20-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for mongreldb_kit-0.64.20-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
mongreldb_kit-0.64.20-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for mongreldb_kit-0.64.20-cp310-abi3-macosx_11_0_arm64.whl
mongreldb_kit-0.64.20-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for mongreldb_kit-0.64.20-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 267.3 MB

Release files / mongreldb_kit-0.64.20-cp310-abi3-win_amd64.whl

Download URL mongreldb_kit-0.64.20-cp310-abi3-win_amd64.whl
Size 50.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d480ff44c1255a175389e2a63ceb944c2a8daf0f1e44f3e3cf8d2c9f86f776d0
BLAKE2b-256 checksum
How to use checksums
7a7f1f0966715e53009e8adf12f0edcd2bcb4af6c1dbb25c5b19a183f3628384
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / mongreldb_kit-0.64.20-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL mongreldb_kit-0.64.20-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 56.2 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
d118cc2dd096b06a9b524aab43e0d508a83eab2a58cfc65d5e6cc4b950e5c2bc
BLAKE2b-256 checksum
How to use checksums
27ca119352ca36b3f26741defe7fa72c98f6ad62b217227d2acbccc9da8ae31e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / mongreldb_kit-0.64.20-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL mongreldb_kit-0.64.20-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 57.9 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
691b50b5bf17fa4f15346fb980b45cf2102a02c1103aeaea23a351e629dabada
BLAKE2b-256 checksum
How to use checksums
7078bd2b41b791dc61a85910ce7e70bdc19234e8e90698d1866d25b0800b31a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / mongreldb_kit-0.64.20-cp310-abi3-macosx_11_0_arm64.whl

Download URL mongreldb_kit-0.64.20-cp310-abi3-macosx_11_0_arm64.whl
Size 50.5 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a24b4a4efde6891f81d7ad073a9242fe26e2e7c142968a45abc37e05e3ba5de0
BLAKE2b-256 checksum
How to use checksums
84fea078a5c7c66be424fbf08c7cd50b254647875fd869b068b4cecf53030cac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / mongreldb_kit-0.64.20-cp310-abi3-macosx_10_12_x86_64.whl

Download URL mongreldb_kit-0.64.20-cp310-abi3-macosx_10_12_x86_64.whl
Size 52.4 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
dbad043d1c0a331dbc0ff92845cf4977b066f74e7266cc1c2ce41393b8d356c5
BLAKE2b-256 checksum
How to use checksums
8037f1e3f0a32128b5551a9e62bc4bda11b46b1ecdad7c0d08905b6881081112
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for mongreldb-kit 0.64.20

Provenance

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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for mongreldb_kit-0.64.20-cp310-abi3-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page