mongodol
Access MongoDB through a Mapping (dict-like) interface.
mongodol wraps pymongo collections as Mapping/MutableMapping objects (readers and
persisters), so you can read and write mongo data with normal dict-like syntax, and
compose your own key/value transforms with dol wrappers
instead of writing backend-specific boilerplate.
To install:
pip install mongodol
And of course, you need a running MongoDB -- see the installation instructions.
For AI agents
mongodol publishes its documentation in forms made for coding agents. If you are one, start here.
The documentation, machine-readable: llms.txt indexes every page; mongodol.md is the whole documentation in one file; every page has a .md twin; objects.inv maps symbols to URLs.
If you are a control freak, the rest of this README is written for you, starting at Quick start.
Quick start
from mongodol import MongoCollectionPersister, mk_dflt_mgc
# mk_dflt_mgc() gives you a pymongo collection to play with (mongodol/mongodol_test by default)
mgc = mk_dflt_mgc()
mgc.delete_many(
{}
) # start from an empty collection (skip this to keep what's already there)
s = MongoCollectionPersister(mgc, getitem_projection={"_id": False})
len(s)
# 0
k = {"_id": "my_id"}
s[k] = {"mongo": "uses", "json": "data"}
list(s)
# [{'_id': 'my_id'}]
Since the base reader is a thin, low-level wrapper, s[k] returns a pymongo.cursor.Cursor
(a key may match zero, one, or many docs), so you fetch the value(s) explicitly:
next(s[k])
# {'mongo': 'uses', 'json': 'data'}
del s[k]
len(s)
# 0
Beyond the base classes
The base MongoCollectionReader/MongoCollectionPersister classes always return cursors
and never validate uniqueness. For the common case of "one key maps to one doc", use one
of the *UniqueDoc*/*FirstDoc* reader and persister classes instead:
from mongodol import MongoCollectionUniqueDocReader
MongoCollectionUniqueDocReader gives you s[k] as a plain dict (not a cursor), and
raises KeyNotUniqueError if more than one doc matches k. See its docstring for a
runnable example.
For custom key/value shapes, business logic, or connecting mongodol stores to the rest
of the dol ecosystem (caching, serialization,
key transforms, etc.), wrap a mongodol store with dol.wrap_kvs like you would any
other dol store.
More
See the package documentation and the flat
mongodol.md aggregate for the full API.
Metadata
Release files for mongodol 0.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mongodol-0.1.10.tar.gz | 62.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mongodol-0.1.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 131.6 kB
Release files / mongodol-0.1.10.tar.gz
| Download URL | mongodol-0.1.10.tar.gz |
|---|---|
| Size | 62.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5769c59e7865835e37d60743b206650d3c06aa5895e57b7755e5da847f224081
|
|
BLAKE2b-256 checksum How to use checksums |
c7bbfc39993c8e742f744e0570eb0a195e4b4db9d9ef1ce5183a4faa33d30902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / mongodol-0.1.10-py3-none-any.whl
| Download URL | mongodol-0.1.10-py3-none-any.whl |
|---|---|
| Size | 69.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b4d80d93fbdba1c45dbe3b58de01a041f68257b0f5fc3514022518806c50bc9
|
|
BLAKE2b-256 checksum How to use checksums |
6dce0ccd70b5106811d155039b32271cc852ec8110acab103dc1d1e101dc7a87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for mongodol 0.1.10
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.