jaraco.modb is a small, pure-Python library for persisting Python objects to MongoDB.
Manual Usage
jaraco.modb facilitates using jsonpickle to produce MongoDB-friendly representations of pickleable Python objects for easy storage in a MongoDB database.
One may simply encode and decode Python objects to MongoDB BSON-friendly representations:
class MyObject(object):
def __init__(self, val):
self.val = val
import jaraco.modb
import pymongo
mongo_collection = pymongo.MongoClient().mydb.mycollection
val = MyObject(3)
# save the object to the DB
id = mongo_collection.save(jaraco.modb.encode(val))
# retrieve the object from the DB
new_val = jaraco.modb.decode(mongo_collection.find_one(id))
assert isinstance(new_val, MyObject)
assert new_val.val == 3
A more detailed tutorial is now published as a Jupyter Notebook.
Automatic Usage
jaraco.modb also provides an SON Manipulator suitable for automatically encoding arbitrary objects for a pymongo.Database:
jaraco.modb.SONManipulator.install(mongo_collection.database)
mongo_collection.save({'val': val})
Unfortunately, due to a limitation with the API of the SONManipulator, it’s not possible to save a custom object as the document itself (the document must always be a dict).
Metadata
Release files for jaraco.modb 6.1.0
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 | Actions |
|---|---|---|---|---|
| jaraco.modb-6.1.0.tar.gz | 13.8 kB | Without provenance | Details for jaraco.modb-6.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jaraco.modb-6.1.0-py3-none-any.whl | Python 3 | none | any | Details for jaraco.modb-6.1.0-py3-none-any.whl |
Total release size: 17.4 kB
Release files / jaraco.modb-6.1.0.tar.gz
| Download URL | jaraco.modb-6.1.0.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55f0d730c05150012b33b814746561bf574bc2399fb5e69a50b13d8c6cb8f8b5
|
|
BLAKE2b-256 checksum How to use checksums |
bec4d93330b6f0d93b78d6644dc926fe7c07c3d3314b891df5ed2e53a25ccb6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|
Release files / jaraco.modb-6.1.0-py3-none-any.whl
| Download URL | jaraco.modb-6.1.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc59eb0e81ef1a6964102813adb9b23129c6401b8dfcddd5c20497ead23c4b12
|
|
BLAKE2b-256 checksum How to use checksums |
98413e8ffe61520c112fc740b57a3f24c36429d3bac83cfac782e8cd89cc2ee5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|
Security for jaraco.modb 6.1.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.