MontyDB
raw JSON → 2.5.6 verified Fri May 01 auth: no python
Monty, Mongo tinified. MongoDB implemented in Python. Current version 2.5.6, supports Python >=3.7. Released irregularly.
pip install montydb Common errors
error ModuleNotFoundError: No module named 'monty' ↓
cause Incorrect import; users attempt 'import monty' instead of 'montydb'.
fix
Run 'pip install montydb' and use 'from montydb import MontyClient'.
error pymongo.errors.ServerSelectionTimeoutError: No primary server found ↓
cause Using pymongo's MongoClient with MontyDB's connection string. MontyDB does not start a real MongoDB server.
fix
Use MontyClient from montydb, not pymongo's MongoClient.
error NotImplementedError: The 'collStats' command is not supported ↓
cause Attempt to use aggregation pipeline operators not implemented by MontyDB (e.g., $collStats).
fix
Replace unsupported operators with equivalent Python code or use simpler queries.
Warnings
gotcha MontyDB's 'import montydb' is correct, but users often mistakenly import 'monty' or 'montydb.client'. ↓
fix Use 'from montydb import MontyClient' or 'from montydb import connect'.
gotcha MontyDB is not fully compatible with all MongoDB features; aggregation pipelines with unsupported operators may raise NotImplementedError. ↓
fix Check the documentation for supported operators; use native Python logic if needed.
breaking Version 2.5.0 introduced support for mongoengine but changed internal storage engine; existing databases may need migration. ↓
fix Back up your montydb data directory before upgrading, or use in-memory mode temporarily.
gotcha In-memory databases are per-process; they do not persist after restart. Users expecting persistence must specify a storage path. ↓
fix Use MontyClient(repository='path/to/data') for persistent file-based storage.
Imports
- MontyClient wrong
from monty import MontyClientcorrectfrom montydb import MontyClient - connect wrong
from pymongo import MongoClientcorrectfrom montydb import connect
Quickstart
from montydb import MontyClient, connect
# Using MontyClient with in-memory storage
client = MontyClient()
db = client.test_db
collection = db.test_collection
collection.insert_one({'name': 'Alice', 'age': 30})
print(collection.find_one({'name': 'Alice'}))