Skip to main content

Small but efficient MongoDB ODM

Project description

μMongo: sync/async ODM

https://img.shields.io/pypi/v/umongo.svg https://img.shields.io/travis/Scille/umongo.svg Documentation Status Code coverage

μMongo is a Python MongoDB ODM. It inception comes from two needs: the lack of async ODM and the difficulty to do document (un)serialization with existing ODMs.

>From this point, μMongo made a few design choices:

  • Stay close to the standards MongoDB driver to keep the same API when possible: use find({"field": "value"}) like usual but retrieve your data nicely OO wrapped !

  • Work with multiple drivers (PyMongo, TxMongo, motor_asyncio and mongomock for the moment)

  • Tight integration with Marshmallow serialization library to easily dump and load your data with the outside world

  • i18n integration to localize validation error messages

  • Free software: MIT license

  • Test with 90%+ coverage ;-)

Quick example

from datetime import datetime
from pymongo import MongoClient
from umongo import Document, fields, validate

db = MongoClient().test

class User(Document):
    email = fields.EmailField(required=True, unique=True)
    birthday = fields.DateTimeField(validate=validate.Range(min=datetime(1900, 1, 1)))
    friends = fields.ListField(fields.ReferenceField("User"))

    class Meta:
        collection = db.user

goku = User(email='goku@sayen.com', birthday=datetime(1984, 11, 20))
goku.commit()
vegeta = User(email='vegeta@over9000.com', friends=[goku])
vegeta.commit()

vegeta.friends
# <object umongo.data_objects.List([<object umongo.dal.pymongo.PyMongoReference(document=User, pk=ObjectId('5717568613adf27be6363f78'))>])>
vegeta.dump()
# {id': '570ddb311d41c89cabceeddc', 'email': 'vegeta@over9000.com', friends': ['570ddb2a1d41c89cabceeddb']}
User.find_one({"email": 'goku@sayen.com'})
# <object Document __main__.User({'_id': ObjectId('570ddb2a1d41c89cabceeddb'), 'friends': <object umongo.data_objects.List([])>,
#                                 'email': 'goku@sayen.com', 'birthday': datetime.datetime(1984, 11, 20, 0, 0)})>

Get it now:

$ pip install umongo

History

0.7.4 (2016-4-21)

  • Fix missing package in setup.py

0.7.3 (2016-4-21)

  • Fix setup.py style preventing from release

0.7.2 (2016-4-21)

  • Fix crash when generating indexes on EmbeddedDocument

0.7.1 (2016-4-21)

  • Fix setup.py not to install tests package

  • Pass status to Beta

0.7.0 (2016-4-21)

  • Add i18n support

  • Add MongoMock support

  • Documentation has been a lot extended

0.6.1 (2016-4-13)

  • Add <dal>_lazy_loader to configure Document’s lazy_collection

0.6.0 (2016-4-12)

  • Heavy improvements everywhere !

0.1.0 (2016-1-22)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

umongo-0.7.4.tar.gz (47.7 kB view details)

Uploaded Source

Built Distribution

umongo-0.7.4-py2.py3-none-any.whl (29.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file umongo-0.7.4.tar.gz.

File metadata

  • Download URL: umongo-0.7.4.tar.gz
  • Upload date:
  • Size: 47.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for umongo-0.7.4.tar.gz
Algorithm Hash digest
SHA256 c8e676669f7ec6d4056b562bf9f111a7da3d88cf16833f4447772231714aff25
MD5 47847aaf4b631b5b827565911983d86b
BLAKE2b-256 6715150a52be7242733049f2840a8ece06d88530249eea90c0653dd6cdd09d91

See more details on using hashes here.

File details

Details for the file umongo-0.7.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for umongo-0.7.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 00ee01ea88e86b7cf7df31fe411ee5640c3118c211d7c651ea59d18b0b51ef0f
MD5 b1dd5f241d6ef0981a519fbbd77310fe
BLAKE2b-256 744cadcfba31ae9dc61a645c22b8519e4bf7db83dec65b41976588e5b2d6c577

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page