Skip to main content

Latest version Build status pre-commit.ci status Documentation Coverage

μMongo is a Python MongoDB ODM. Its 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

import datetime as dt
from pymongo import MongoClient
from umongo import Document, fields, validate
from umongo.frameworks import PyMongoInstance

db = MongoClient().test
instance = PyMongoInstance(db)


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

    class Meta:
        collection_name = "user"


# Make sure that unique indexes are created
User.ensure_indexes()

goku = User(email="goku@sayen.com", birthday=dt.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           # This installs umongo with pymongo
$ pip install my-mongo-driver  # Other MongoDB drivers must be installed manually

Or to get it along with the MongoDB driver you’re planing to use:

$ pip install umongo[motor]
$ pip install umongo[txmongo]
$ pip install umongo[mongomock]

Support umongo

If you’d like to support the future of the project, please consider contributing to Marshmallow’s Open Collective:

Donate to our collective

Download files

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

Source Distribution

umongo-4.0.0.tar.gz (175.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

umongo-4.0.0-py3-none-any.whl (45.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: umongo-4.0.0.tar.gz
  • Upload date:
  • Size: 175.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for umongo-4.0.0.tar.gz
Algorithm Hash digest
SHA256 6c9e9d0795924397658f5b013cb0bac96b8e2f562358e40ba10de1143bbe79be
MD5 c244ecb5f07e8dd0180ac03f88e48ff0
BLAKE2b-256 e6afe012442938077251dda607f4653c4999a9aeb1bcd43889127b23e3d0135e

See more details on using hashes here.

Provenance

The following attestation bundles were made for umongo-4.0.0.tar.gz:

Publisher: build-release.yml on Scille/umongo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file umongo-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: umongo-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 45.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for umongo-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 34a1ea6ef90fc669d3db657cfd43772da1e7c28539424e250b637d5c734fda4b
MD5 f2e62bb047f51ac5c23774b5d010cbbf
BLAKE2b-256 aa87e1723a240bc5785abb25bbd2ec3096710bdd98197b0f29243af7d2d0db94

See more details on using hashes here.

Provenance

The following attestation bundles were made for umongo-4.0.0-py3-none-any.whl:

Publisher: build-release.yml on Scille/umongo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

4.0.0 This release

2 files

3.1.0

2 files

3.0.1

2 files

3.0.0

2 files

2.3.0

2 files

2.2.0

2 files

2.1.1

2 files

2.1.0

2 files

2.0.5

2 files

2.0.4

2 files

2.0.3

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

0.15.0

2 files

0.14.0

2 files

0.13.0

2 files

0.12.0

2 files

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

0.8.1

2 files

0.8.0

2 files

0.7.8

2 files

0.7.6

2 files

0.7.5

1 file

0.7.4

2 files

0.7.3

2 files

0.7.0

2 files

0.6.1

2 files

0.6.0

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.1

2 files

0.3.4

2 files

0.3.3

2 files

0.3.0

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page