HumbleDB - MongoDB Object-Document Mapper
Project description
HumbleDB - MongoDB Object-Document Mapper
HumbleDB solves the age-old MongoDB dilemma: write readable, maintainable code or optimize for storage efficiency. With HumbleDB, you get both. This lightweight ODM lets you use clear, descriptive attribute names in your Python code while automatically mapping them to ultra-short database keys, dramatically reducing document size and memory usage without sacrificing code clarity.
[!WARNING] Version 7.0.0 Breaking Changes This release updates to Pymongo 4.x, which introduces breaking changes. While we've maintained all older 3.x and 2.x Pymongo methods with identical signatures where possible, there may be other breaking changes not covered by our test suite. If you encounter any issues during upgrade, please open an issue.
Features
Efficient Storage: Map readable attribute names to ultra-short database keys, reducing document size and memory usage while maintaining code clarity.
Full Pymongo Compatibility: Maintains backwards-compatible methods for
Pymongo 4.x including insert, find_and_modify, save, and other familiar
operations.
Maximum Flexibility: Documents are also dictionaries - no schema restrictions, maximum adaptability to changing requirements.
Thread & Greenlet Safe: Built for concurrent applications with safe connection handling and resource management.
Context-Managed Connections: Connection paradigm minimizes socket usage from the connection pool through explicit context managers.
Lightweight Design: Thin wrapper around Pymongo that exposes the full power of the underlying driver without performance overhead.
Quick Start
Define Your Document Schema
Create a Document
subclass with readable attribute names mapped to short database keys:
from humbledb import Mongo, Document
class TestDoc(Document):
config_database = 'test' # Target database
config_collection = 'testdoc' # Target collection
test_key = 't' # Maps 'test_key' attribute to 't' in MongoDB
other_key = 'o' # Maps 'other_key' attribute to 'o' in MongoDB
Create and Populate Documents
Documents work like regular Python objects with attribute access, while storing data efficiently:
doc = TestDoc()
doc.test_key = 'Hello'
doc.other_key = 'World'
# View the actual MongoDB document structure
print(doc)
# TestDoc({'t': 'Hello', 'o': 'World'})
Flexible Data Access
Access your data through mapped attributes or direct dictionary keys:
# Via mapped attributes (recommended)
print(doc.test_key) # 'Hello'
# Via dictionary access
print(doc['t']) # 'Hello'
print(doc['o']) # 'World'
Database Operations
Use the Mongo
context manager for safe database operations:
# Insert document
with Mongo:
TestDoc.insert(doc)
# Query documents
with Mongo:
found = TestDoc.find_one()
print(found)
# TestDoc({'_id': ObjectId('50ad81586112797f89b99606'), 't': 'Hello', 'o': 'World'})
See the documentation for more examples and detailed explanations.
Documentation
The complete documentation can be found on http://humbledb.readthedocs.org.
License
See LICENSE.rst.
Contributors
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 humbledb-7.0.0.tar.gz.
File metadata
- Download URL: humbledb-7.0.0.tar.gz
- Upload date:
- Size: 32.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
859179df7e65e5a6fad61ef8c05934ae3892b48647d92b6672bda6925ef0ac7c
|
|
| MD5 |
f2e93d5ec7185840e7d6321734d6d709
|
|
| BLAKE2b-256 |
b57fb2f82d5e18fe9d91e8eff52677e191ca92fc832220f67c0f240c60dd30a7
|
Provenance
The following attestation bundles were made for humbledb-7.0.0.tar.gz:
Publisher:
release.yaml on shakefu/humbledb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
humbledb-7.0.0.tar.gz -
Subject digest:
859179df7e65e5a6fad61ef8c05934ae3892b48647d92b6672bda6925ef0ac7c - Sigstore transparency entry: 246034458
- Sigstore integration time:
-
Permalink:
shakefu/humbledb@bcf9935d83f038a9cd9d9202c5e9067268f9637b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shakefu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@bcf9935d83f038a9cd9d9202c5e9067268f9637b -
Trigger Event:
push
-
Statement type:
File details
Details for the file humbledb-7.0.0-py3-none-any.whl.
File metadata
- Download URL: humbledb-7.0.0-py3-none-any.whl
- Upload date:
- Size: 35.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5755dc1a68e4f3ae37fa4525af99e9983334df4bfa99db290edda121171fa97
|
|
| MD5 |
467e68412f0cf8d16c1cb7e0e1cad2db
|
|
| BLAKE2b-256 |
228b76f68a2dafb0f47b951bb6f689bae27ed208711105c07af6442c1f4e3a49
|
Provenance
The following attestation bundles were made for humbledb-7.0.0-py3-none-any.whl:
Publisher:
release.yaml on shakefu/humbledb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
humbledb-7.0.0-py3-none-any.whl -
Subject digest:
b5755dc1a68e4f3ae37fa4525af99e9983334df4bfa99db290edda121171fa97 - Sigstore transparency entry: 246034460
- Sigstore integration time:
-
Permalink:
shakefu/humbledb@bcf9935d83f038a9cd9d9202c5e9067268f9637b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shakefu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@bcf9935d83f038a9cd9d9202c5e9067268f9637b -
Trigger Event:
push
-
Statement type: