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
- Iteration is key order, not insertion order.
- Keys are
str | int | bytes | tupleof those.float,bool, andNoneraiseTypeError; anintoutside 64 bits raisesValueError. - Values must be mappings — a dict, dataclass instance, or model.
keys(),values(),items()are snapshot iterators, not live views."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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f00231f7005838a20d4ba9d33e90bd5fdf1fce61e4e399cc6033cb436ccd042
|
|
| MD5 |
cc85d145f04f1b9128b7aae70d93e8ce
|
|
| BLAKE2b-256 |
7c1c4a0ab2eb24f959fc51e527265de6185a79175f283bbf82f250fa34514e05
|
Provenance
The following attestation bundles were made for monadb-0.2.0.tar.gz:
Publisher:
release.yml on rchowell/MonaDB
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
monadb-0.2.0.tar.gz -
Subject digest:
9f00231f7005838a20d4ba9d33e90bd5fdf1fce61e4e399cc6033cb436ccd042 - Sigstore transparency entry: 2331267708
- Sigstore integration time:
-
Permalink:
rchowell/MonaDB@b163c95db379be52066293d042e52405bf6bcd32 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/rchowell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b163c95db379be52066293d042e52405bf6bcd32 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c41a23f383b89507127dc895ceb00133bc1dbcd7933789119456008405e21b0
|
|
| MD5 |
c60ff974e94b466bdbc4ffffeaf0abad
|
|
| BLAKE2b-256 |
e3a71697a1f44a2313ab83e5474a2f3f95046c50842793c800072f482fa8bac1
|
Provenance
The following attestation bundles were made for monadb-0.2.0-cp39-abi3-win_amd64.whl:
Publisher:
release.yml on rchowell/MonaDB
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
monadb-0.2.0-cp39-abi3-win_amd64.whl -
Subject digest:
7c41a23f383b89507127dc895ceb00133bc1dbcd7933789119456008405e21b0 - Sigstore transparency entry: 2331268874
- Sigstore integration time:
-
Permalink:
rchowell/MonaDB@b163c95db379be52066293d042e52405bf6bcd32 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/rchowell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b163c95db379be52066293d042e52405bf6bcd32 -
Trigger Event:
push
-
Statement type:
File details
Details for the file monadb-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: monadb-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 739.1 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68c3da5d86222faf2b72b3073dea2e2a9e2a104833d0bce6b51f01d3fcb95bba
|
|
| MD5 |
e5a7de38eb1b1ea8f9f644df4c9f610f
|
|
| BLAKE2b-256 |
f7fa2d7175b4b9e9129267c3c5142cc6c3a9584ac957fffe0999dadd1d20a549
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
monadb-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
68c3da5d86222faf2b72b3073dea2e2a9e2a104833d0bce6b51f01d3fcb95bba - Sigstore transparency entry: 2331268193
- Sigstore integration time:
-
Permalink:
rchowell/MonaDB@b163c95db379be52066293d042e52405bf6bcd32 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/rchowell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b163c95db379be52066293d042e52405bf6bcd32 -
Trigger Event:
push
-
Statement type:
File details
Details for the file monadb-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: monadb-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 703.6 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f99dbd8e3b8e813d796f35fb6d26131d141a88639ccabe7e772f6435467fc6cc
|
|
| MD5 |
7e7960eb4e79349e84806fda52e6b969
|
|
| BLAKE2b-256 |
3ecd6806fe3a4d95739c0625efbe8b55cde81cf3dee33e23984c6f08a9af8f7a
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
monadb-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
f99dbd8e3b8e813d796f35fb6d26131d141a88639ccabe7e772f6435467fc6cc - Sigstore transparency entry: 2331268464
- Sigstore integration time:
-
Permalink:
rchowell/MonaDB@b163c95db379be52066293d042e52405bf6bcd32 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/rchowell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b163c95db379be52066293d042e52405bf6bcd32 -
Trigger Event:
push
-
Statement type:
File details
Details for the file monadb-0.2.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: monadb-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 650.1 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
deba40f5e5119af880c17cc9cd0a65fdfb82262c65a6c9de351ed8a0bbf2447a
|
|
| MD5 |
34bac6f308eb171ec9b7ded2b9692c79
|
|
| BLAKE2b-256 |
42b25ee29ab4ee77a37ea359e21a1c7652660ee34bea75f845a8664fb74adb82
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
monadb-0.2.0-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
deba40f5e5119af880c17cc9cd0a65fdfb82262c65a6c9de351ed8a0bbf2447a - Sigstore transparency entry: 2331267993
- Sigstore integration time:
-
Permalink:
rchowell/MonaDB@b163c95db379be52066293d042e52405bf6bcd32 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/rchowell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b163c95db379be52066293d042e52405bf6bcd32 -
Trigger Event:
push
-
Statement type:
File details
Details for the file monadb-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: monadb-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 678.2 kB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d364178b2377d3ea950398af04b3a9ecf94b5f2ec2807d440ca184bdbfbbefb
|
|
| MD5 |
b5d7c076877f500eaf70a9feec554df8
|
|
| BLAKE2b-256 |
28f4f7e57e1530121f7c56e5ad9a17c3d4f279fe9668a39ce2b663bd2665e8d7
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
monadb-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl -
Subject digest:
8d364178b2377d3ea950398af04b3a9ecf94b5f2ec2807d440ca184bdbfbbefb - Sigstore transparency entry: 2331268639
- Sigstore integration time:
-
Permalink:
rchowell/MonaDB@b163c95db379be52066293d042e52405bf6bcd32 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/rchowell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b163c95db379be52066293d042e52405bf6bcd32 -
Trigger Event:
push
-
Statement type: