Skip to main content

MonaDB

An embedded document store with Python dict semantics, built on redb. Documents are stored as BSON.

pip install monadb
import monadb

db = monadb.open("app.db")        # or monadb.open() for in-memory

db["users"]["alice"] = {"age": 30}
db["users"]["alice"]              # {"age": 30}
"alice" in db["users"]
len(db["users"])
del db["users"]["alice"]

Every operation is its own commit. update() is one commit for the whole mapping, so a bad item leaves nothing behind:

db["users"].update({"bob": {"age": 41}, "cy": {"age": 9}})

Ordered operations

Keys use an order-preserving encoding, so the b-tree's ordering is directly available:

events.range(start, stop)   # half-open [start, stop); None means unbounded
events.prefix("2026-08")    # str/bytes prefix, or a tuple of leading components
events.first(); events.last()
reversed(events)

Models

A collection is plain-dict by default and can be bound to a type. Binding is a property of the handle — nothing about the type is stored, so the same data is always readable as dicts.

from dataclasses import dataclass

@dataclass
class User:
    name: str
    age: int

users = db.collection("users", User)
users["alice"] = User(name="alice", age=30)
users["alice"]                    # User(name='alice', age=30)
db["users"]["alice"]              # {"name": "alice", "age": 30}

pydantic models work the same way, recognized by shape — MonaDB never imports pydantic.

How it differs from dict

  1. Iteration is key order, not insertion order.
  2. Keys are str | int | bytes | tuple of those. float, bool, and None raise TypeError; an int outside 64 bits raises ValueError.
  3. Values must be mappings — a dict, dataclass instance, or model.
  4. keys(), values(), items() are snapshot iterators, not live views.
  5. "a" and ("a",) are the same key — a scalar is a 1-component tuple.

Concurrency

Readers never block: redb is MVCC, so an open iterator keeps its own snapshot. Writers serialize — a second writer waits for the first to commit.

Only one process may open a database for writing. redb takes an exclusive file lock; several processes may open the same file read-only. This is the one capability 0.2 gives up relative to 0.1, which used LMDB.

Durability

durable=False trades commit durability for speed, which suits bulk loads:

db = monadb.open("app.db", durable=False)

Exceptions

monadb.Error covers storage faults and use of a closed database. Everything else is a Python builtin — KeyError, TypeError, ValueError.

Requirements

Python 3.9+. Building from source needs Rust 1.85+ (edition 2024).

Versions

0.2 is a rewrite. The SQL engine MonaDB shipped through 0.1 is preserved under the v0.1.0-sql git tag, and pip install "monadb<0.2" still installs it. Databases written by 0.1 cannot be read by 0.2.

License

Apache-2.0 — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

monadb-0.2.0.tar.gz (85.6 kB view details)

Uploaded Source

Built Distributions

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

monadb-0.2.0-cp39-abi3-win_amd64.whl (555.3 kB view details)

Uploaded CPython 3.9+Windows x86-64

monadb-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (739.1 kB view details)

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

monadb-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (703.6 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

monadb-0.2.0-cp39-abi3-macosx_11_0_arm64.whl (650.1 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

monadb-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl (678.2 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file monadb-0.2.0.tar.gz.

File metadata

  • Download URL: monadb-0.2.0.tar.gz
  • Upload date:
  • Size: 85.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for monadb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9f00231f7005838a20d4ba9d33e90bd5fdf1fce61e4e399cc6033cb436ccd042
MD5 cc85d145f04f1b9128b7aae70d93e8ce
BLAKE2b-256 7c1c4a0ab2eb24f959fc51e527265de6185a79175f283bbf82f250fa34514e05

See more details on using hashes here.

Provenance

The following attestation bundles were made for monadb-0.2.0.tar.gz:

Publisher: release.yml on rchowell/MonaDB

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

File details

Details for the file monadb-0.2.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: monadb-0.2.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 555.3 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for monadb-0.2.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7c41a23f383b89507127dc895ceb00133bc1dbcd7933789119456008405e21b0
MD5 c60ff974e94b466bdbc4ffffeaf0abad
BLAKE2b-256 e3a71697a1f44a2313ab83e5474a2f3f95046c50842793c800072f482fa8bac1

See more details on using hashes here.

Provenance

The following attestation bundles were made for monadb-0.2.0-cp39-abi3-win_amd64.whl:

Publisher: release.yml on rchowell/MonaDB

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

File details

Details for the file monadb-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for monadb-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 68c3da5d86222faf2b72b3073dea2e2a9e2a104833d0bce6b51f01d3fcb95bba
MD5 e5a7de38eb1b1ea8f9f644df4c9f610f
BLAKE2b-256 f7fa2d7175b4b9e9129267c3c5142cc6c3a9584ac957fffe0999dadd1d20a549

See more details on using hashes here.

Provenance

The following attestation bundles were made for monadb-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on rchowell/MonaDB

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

File details

Details for the file monadb-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for monadb-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f99dbd8e3b8e813d796f35fb6d26131d141a88639ccabe7e772f6435467fc6cc
MD5 7e7960eb4e79349e84806fda52e6b969
BLAKE2b-256 3ecd6806fe3a4d95739c0625efbe8b55cde81cf3dee33e23984c6f08a9af8f7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for monadb-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on rchowell/MonaDB

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

File details

Details for the file monadb-0.2.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for monadb-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 deba40f5e5119af880c17cc9cd0a65fdfb82262c65a6c9de351ed8a0bbf2447a
MD5 34bac6f308eb171ec9b7ded2b9692c79
BLAKE2b-256 42b25ee29ab4ee77a37ea359e21a1c7652660ee34bea75f845a8664fb74adb82

See more details on using hashes here.

Provenance

The following attestation bundles were made for monadb-0.2.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on rchowell/MonaDB

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

File details

Details for the file monadb-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for monadb-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8d364178b2377d3ea950398af04b3a9ecf94b5f2ec2807d440ca184bdbfbbefb
MD5 b5d7c076877f500eaf70a9feec554df8
BLAKE2b-256 28f4f7e57e1530121f7c56e5ad9a17c3d4f279fe9668a39ce2b663bd2665e8d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for monadb-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on rchowell/MonaDB

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 Sentry Error logging StatusPage Status page