A Python Object-Document-Mapper for working with MongoDB

Overview

MongoEngine

Info: MongoEngine is an ORM-like layer on top of PyMongo.
Repository: https://github.com/MongoEngine/mongoengine
Author: Harry Marr (http://github.com/hmarr)
Maintainer: Stefan Wójcik (http://github.com/wojcikstefan)
https://travis-ci.org/MongoEngine/mongoengine.svg?branch=master https://coveralls.io/repos/github/MongoEngine/mongoengine/badge.svg?branch=master

About

MongoEngine is a Python Object-Document Mapper for working with MongoDB. Documentation is available at https://mongoengine-odm.readthedocs.io - there is currently a tutorial, a user guide, and an API reference.

Supported MongoDB Versions

MongoEngine is currently tested against MongoDB v3.4, v3.6 and v4.0. Future versions should be supported as well, but aren't actively tested at the moment. Make sure to open an issue or submit a pull request if you experience any problems with MongoDB version > 4.0.

Installation

We recommend the use of virtualenv and of pip. You can then use python -m pip install -U mongoengine. You may also have setuptools and thus you can use easy_install -U mongoengine. Another option is pipenv. You can then use pipenv install mongoengine to both create the virtual environment and install the package. Otherwise, you can download the source from GitHub and run python setup.py install.

The support for Python2 was dropped with MongoEngine 0.20.0

Dependencies

All of the dependencies can easily be installed via python -m pip. At the very least, you'll need these two packages to use MongoEngine:

  • pymongo>=3.4

If you utilize a DateTimeField, you might also use a more flexible date parser:

  • dateutil>=2.1.0

If you need to use an ImageField or ImageGridFsProxy:

  • Pillow>=2.0.0

If you need to use signals:

  • blinker>=1.3

Examples

Some simple examples of what MongoEngine code looks like:

from mongoengine import *
connect('mydb')

class BlogPost(Document):
    title = StringField(required=True, max_length=200)
    posted = DateTimeField(default=datetime.datetime.utcnow)
    tags = ListField(StringField(max_length=50))
    meta = {'allow_inheritance': True}

class TextPost(BlogPost):
    content = StringField(required=True)

class LinkPost(BlogPost):
    url = StringField(required=True)

# Create a text-based post
>>> post1 = TextPost(title='Using MongoEngine', content='See the tutorial')
>>> post1.tags = ['mongodb', 'mongoengine']
>>> post1.save()

# Create a link-based post
>>> post2 = LinkPost(title='MongoEngine Docs', url='hmarr.com/mongoengine')
>>> post2.tags = ['mongoengine', 'documentation']
>>> post2.save()

# Iterate over all posts using the BlogPost superclass
>>> for post in BlogPost.objects:
...     print('===', post.title, '===')
...     if isinstance(post, TextPost):
...         print(post.content)
...     elif isinstance(post, LinkPost):
...         print('Link:', post.url)
...

# Count all blog posts and its subtypes
>>> BlogPost.objects.count()
2
>>> TextPost.objects.count()
1
>>> LinkPost.objects.count()
1

# Count tagged posts
>>> BlogPost.objects(tags='mongoengine').count()
2
>>> BlogPost.objects(tags='mongodb').count()
1

Tests

To run the test suite, ensure you are running a local instance of MongoDB on the standard port and have pytest installed. Then, run python setup.py test or simply pytest.

To run the test suite on every supported Python and PyMongo version, you can use tox. You'll need to make sure you have each supported Python version installed in your environment and then:

# Install tox
$ python -m pip install tox
# Run the test suites
$ tox

If you wish to run a subset of tests, use the pytest convention:

# Run all the tests in a particular test file
$ pytest tests/fields/test_fields.py
# Run only particular test class in that file
$ pytest tests/fields/test_fields.py::TestField

Community

Contributing

We welcome contributions! See the Contribution guidelines

Issues
  • Pymongo3 compatibility

    Pymongo3 compatibility

    Hi guys,

    Now everything is fixed and is fully compatible for both PyMongo 2.X and 3.X

    I'm awaiting some feedback for:

    1. ~~The way I introduced differential behaviour based on PyMongo version~~
    2. ~~The behaviour for save() when a document is created with a given primary key, source of 5 of remaining issues. Here particularly, I have removed the check for self._created since we used to modify this why changing/switching db on the fly. This whole behaviour has changed in PyMongo3 and IMHO doesn't make sense anymore.~~
    3. ~~Your opinion if the test_hint failure could point to a bug in PyMongo3~~
    4. ~~A hand on the other error on test_geo_indexes_recursion~~
    5. ~~A problem with binary field used as primary index that was always there and only discovered now by a better test that became mandatory by the use of a work-around concerning a PyMongo 3.0 bug already fixed in the upcoming 3.0.1~~

    Cheers, Matthieu

    Review on Reviewable

    opened by MRigal 113
  • Tox support for cross-versions testing

    Tox support for cross-versions testing

    Mongoengine is tested on different PyMongo versions, different Python versions... This pull-request add a tox.ini file allowing to run the test suite on every supported version composition . This allow to do proper testing before submitting pull-requests without having to wait for TravisCI cross-versions testing.

    To run the test in tox, simply run:

    $ tox
    

    It will create a virtualenv for each combination and run the same test suite (like TravisCI).

    Review on Reviewable

    opened by noirbizarre 78
  • Fixes #934 - Added option to disable field existence check.

    Fixes #934 - Added option to disable field existence check.

    I threw together this patch as an idea to fix #934.

    I haven't dug too deep into Mongoengine to know what else this might affect, but I used _from_son in BaseDocument object as my injection point. The idea being that if one tries to define in code a field that does not exist, an error is still raised, but if one pulls in data from a PyMongo object, we don't raise an error.

    Review on Reviewable

    opened by gordol 64
  • mark_as_changed issue

    mark_as_changed issue

    fix mark_as_changed: rm lower level changed fields otherwise may cause conflict update error this issue appears when retrieve from db

    In [34]: class Foo(mongoengine.Document):
    
        bar = mongoengine.DictField()
       ....:     
    
    In [35]: Foo.objects.delete()
    Out[35]: 1
    
    In [36]: foo = Foo()
    
    In [37]: foo.save()
    Out[37]: <Foo: Foo object>
    
    In [38]: foo = Foo.objects.first()
    
    In [39]: foo.bar['what'] = 'ever'
    
    In [40]: foo.bar['other'] = {}
    
    In [41]: foo._changed_fields
    Out[41]: ['bar.what', 'bar.other']
    
    In [42]: foo.bar['other']['what'] = 'ever'
    
    In [43]: foo._changed_fields
    Out[43]: ['bar.what', 'bar.other', 'bar.other.what']
    
    In [44]: foo.save()
    ---------------------------------------------------------------------------
    OperationError                            Traceback (most recent call last)
    <ipython-input-44-e6645f54a3c0> in <module>()
    ----> 1 foo.save()
    
    .../mongoengine/document.pyc in save(self, force_insert, validate, clean, write_concern, cascade, cascade_kwargs, _refs, save_condition, **kwargs)
        365                 message = u'Tried to save duplicate unique keys (%s)'
        366                 raise NotUniqueError(message % unicode(err))
    --> 367             raise OperationError(message % unicode(err))
        368         id_field = self._meta['id_field']
        369         if created or id_field not in self._meta.get('shard_key', []):
    
    OperationError: Could not save document (Cannot update 'bar.other' and 'bar.other.what' at the same time)
    

    Review on Reviewable

    opened by Catstyle 53
  • _get_changed_fields fix for embedded documents with id field.

    _get_changed_fields fix for embedded documents with id field.

    When id field presented in Embedded document, changes inside this document was ignored in method _get_changed_fields because it's id was added to inspected array before processing it fields. Also modify unittests for _delta method, which fails without code modification.

    Review on Reviewable

    opened by elephanter 45
  • Release MongoEngine 0.9

    Release MongoEngine 0.9

    Adding a tracking ticket for the MongoEngine 0.9 release.

    I'm not sure whats required for the release but I can point people to a ticket to watch ;)

    opened by rozza 35
  • Check if undefined fields are supplied on document

    Check if undefined fields are supplied on document

    If an undefined field is supplied to a document instance, a FieldDoesNotExist Exception will be raised. This way, you will be notified when you provide a field that does not exist.

    ATM when you do this:

    MyDoc(undefined_field="test")
    

    It will create a document instance for MyDoc. However, if undefined_field does not exist, the value test won't end up anywhere. You'll think the object is successfully created with the provided values, but actually it isn't.

    To remedy this situation, an exception will be raised. This way you'll be noticed about your mistake in development. If the document instance is created dynamically on bases of an API call data for example, then you can catch the exeption and notify the API user that they have provided an undefined field.

    opened by gitaarik 28
  • Delete returns None but expected a dict

    Delete returns None but expected a dict

    I'm trying to delete a document with self.delete() but it raises and error: File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 467, in delete return result["n"] TypeError: 'NoneType' object has no attribute 'getitem'

    I've checked the result with print result and it is None The deletion is made ok but the try to return result["n"] raises and error because result is None

    Did I missed something or did I find a bug?

    Thanks!

    Bug 
    opened by Garito 28
  • save doesn't work for datetime consistent with other fields.

    save doesn't work for datetime consistent with other fields.

    I am new to mongoengine, but this doesn't make any sense to me, that when I call my my_update() function, the user's updated_at field doesnt get updated but other fields do. here is my model:

    class User(db.Document):
        username = db.StringField(required=True, unique=True, max_length=20)
        created_at = db.DateTimeField(default=datetime.datetime.utcnow())
        updated_at = db.DateTimeField()
        friend_list = ListField(StringField(max_length=100))
    

    when I do a save, it saves the new friend_list correctly but it keeps the old updated_at field, and that one will never get updated again.

    def my_update(user_id):
        form = UserForm()
        user = User.objects.get_or_404(id=user_id)
        user.friend_list = insert_random_data()
        user.updated_at = datetime.datetime.utcnow()
        user.save()
        return users = User.objects.order_by('-updated_at', '-created_at')
    

    so if I run my_update a few times, it will update the friend_list each time, but the update_at field keeps staying the same !!! and I have no idea. I am really curious why is it behaving like this !

    opened by medyagh 27
  • Pep8 and more clean-up

    Pep8 and more clean-up

    Hi guys,

    Several times I ran into some cases where I came across these init() method returning a value, or some unused statements or variables, as well as many pep8 issues. It is never great to make a big change, but since we are now cleaning so many PRs and there will be anyway a big PR with #946 for next version, I thought it could be a good time to clean generally some code.

    I took some time to really read once (quickly) all the code line by line. It allowed me also to find some issues or strange behaviour and to add some TODOs.

    I would also like to take the opportunity to tackle one other point. We want to be PEP8 conform and this is very good. However one point is at least vague: line length. We have in our code some pieces which are strictly limited to 79 characters and some others to 119.

    PEP8 recommends 79 characters, however Django makes some exceptions there: https://docs.djangoproject.com/en/1.8/internals/contributing/writing-code/coding-style/

    Should we include the same point in our contribution guidelines? Some PRs have a lot of code doing only line breaks clean-up (which I tried to avoid in this cleaning effort to avoid unnecessary changes). And at the same time, I see a lot of places in the code where we have line breaks that do make the code significantly harder to read. @rozza @DavidBord @thedrow @seglberg @yograterol can I have your opinion on that point?

    Review on Reviewable

    opened by MRigal 27
  • Update with aggregation pipeline

    Update with aggregation pipeline

    Update with aggregation pipeline

    I add support to update with aggregation pipeline The only option to do that is create new parameter to the update query and enforce use raw if someone find way to use update with aggregation with mongoengine it will be brilliant

    thanks

    https://docs.mongodb.com/manual/referenc e/method/db.collection.updateMany/#update-with-aggregation-pipeline

    opened by idoshr 1
  • Feature/raise not retrieved field exception

    Feature/raise not retrieved field exception

    null

    opened by kassymkhanTJ 0
  • add ordered argument to insert method

    add ordered argument to insert method

    fix #2169

    opened by omaxx 0
  • Transactions via an internal global session var

    Transactions via an internal global session var

    An implementation of one of my proposals in https://github.com/MongoEngine/mongoengine/issues/2248#issuecomment-908504024

    • Maintain state of session when entering and exiting transaction
    • Update any collection methods used in mongoengine that accept session
    • Update any database methods used in mongoengine that accept session
    • Cascades should be accounted for as those methods are wrappers which call the same low-level pymongo collection APIs updated above
    • Any signals that try to read or write should also be wrapped in the transaction
    opened by juannyG 5
  • Solve the problem of repeatedly clearing complex nested documents

    Solve the problem of repeatedly clearing complex nested documents

    Increase the cache to solve the problem that the same clean function will be called multiple times for nested objects with arrays, resulting in the performance of complex documents under high concurrency

    opened by piaoxue1949 0
  • Fix error if DBRef exists in DynamicEmbeddedDocument

    Fix error if DBRef exists in DynamicEmbeddedDocument

    If assign a document to DynamicEmbeddedDocument, DBRef will be used to store the reference. The data can be stored successfully. But mongoengine.errors.FieldDoesNotExist error raised while reading the data from the database.

    class Tag(Document):
        meta = {"collection": "tags"}
        name = StringField()
    
    class Post(DynamicEmbeddedDocument):
        pass
    
    class Page(Document):
        meta = {"collection": "pages"}
        post = EmbeddedDocumentField(Post)
    
    tag = Tag(name="test").save()
    post = Post(book_tag=tag)
    Page(post=post).save()
    
    page = Page.objects.first()  # mongoengine.errors.FieldDoesNotExist raised here
    

    Error message: mongoengine.errors.FieldDoesNotExist: The fields "{'_ref'}" do not exist on the document "XXX" Solution: Dereference the field value if it is a dict with both '_cls' and '_ref' in it.

    opened by spengjie 0
  • Docker/compose for local development

    Docker/compose for local development

    Per https://github.com/MongoEngine/mongoengine/issues/2555 - this provides a Dockerized mongo 4 container with a replica set of 1, primed and ready to go.

    If you don't have a mongo instance running already, you can use Docker

    docker build -t mongoengine:latest .
    docker run -it -p 27017:27017 mongoengine:latest
    

    or docker-compose:

    docker-compose build
    docker-compose up
    
    opened by juannyG 0
  • Inconsistent behavior of auth options in host string and kwarg when connect

    Inconsistent behavior of auth options in host string and kwarg when connect

    Background

    MongoDB version: 4.2.6 mongoengine version: 0.23.1 pymongo: 3.12.0

    In my scenario, I need to connect with authentication_source and authentication_mechanism and then do some queries.

    My code goes like this,

    class User(Document):
        name = StringField()
    
    # connect
    connect(
        host='mongodb://{username}:{password}@{host}:{port}/{db}'.format(**MONGO_CONFIG),
        authentication_mechanism=MONGO_CONFIG['mechanism'],
        authentication_source=MONGO_CONFIG['db']
    )
    
    # query
    User.objects.count()
    

    Analysis

    1. If auth options to be a kwarg of connect

    authentication_mechanism and authentication_source will be cleaned when _create_connection,

    https://github.com/MongoEngine/mongoengine/blob/5fe9436ea7bd2f47812b017104285210848a1276/mongoengine/connection.py#L265-L275

    And will get MongoCredential in pymongo like this when connect,

    MongoCredential(mechanism='DEFAULT', source='s', username='u', password='p', mechanism_properties=None, cache=<pymongo.auth._Cache object at 0x7f9aa2db0e50>)
    

    The error will be raised when we do a query or a count op, because the new MongoCredential is different

    Traceback (most recent call last):
      File "debug.py", line 27, in <module>
        User.objects.count()
      File "/Users/.../opt/anaconda3/envs/mongoengine-pr/lib/python3.7/site-packages/mongoengine/queryset/manager.py", line 38, in __get__
        queryset = queryset_class(owner, owner._get_collection())
      File "/Users/.../opt/anaconda3/envs/mongoengine-pr/lib/python3.7/site-packages/mongoengine/document.py", line 215, in _get_collection
        db = cls._get_db()
      File "/Users/.../opt/anaconda3/envs/mongoengine-pr/lib/python3.7/site-packages/mongoengine/document.py", line 193, in _get_db
        return get_db(cls._meta.get("db_alias", DEFAULT_CONNECTION_NAME))
      File "/Users/.../opt/anaconda3/envs/mongoengine-pr/lib/python3.7/site-packages/mongoengine/connection.py", line 368, in get_db
        conn_settings["username"], conn_settings["password"], **auth_kwargs
      File "/Users/.../opt/anaconda3/envs/mongoengine-pr/lib/python3.7/site-packages/pymongo/database.py", line 1575, in authenticate
        connect=True)
      File "/Users/.../opt/anaconda3/envs/mongoengine-pr/lib/python3.7/site-packages/pymongo/mongo_client.py", line 806, in _cache_credentials
        raise OperationFailure('Another user is already authenticated '
    pymongo.errors.OperationFailure: Another user is already authenticated to this database. You must logout first.
    
    MongoCredential(mechanism='SCRAM-SHA-256', source='s', username='u', password='p', mechanism_properties=None, cache=<pymongo.auth._Cache object at 0x7f9fe769b390>)
    

    authentication_mechanism

    The root cause of this issue is that the get_db function is handling the transform (mongoengine's authentication_mechanism to pymongo's mechanism) when a query is taking off. However, that is not happening during the connection phase.

    https://github.com/MongoEngine/mongoengine/blob/5fe9436ea7bd2f47812b017104285210848a1276/mongoengine/connection.py#L356

    authentication_source

    authentication_source is not handling during the connection phase too. But this will be set as db name by default in pymongo.

    2. If auth options to be in the host string

    Everything goes fine in this situation because pymongo will parse the host string and set them correctly. Like,

    connect(host='mongodb://{username}:{password}@{host}:{port}/{db}?authMechanism={mechanism}&authSource={db}'.format(**MONGO_CONFIG))
    

    https://github.com/mongodb/mongo-python-driver/blob/2eb0df812c6a4afbdbcd12692ca8da0b4dd0c14e/pymongo/mongo_client.py#L659

    So should we reconcile them?

    opened by ryantd 0
  • Image Field put() silently compresses jpg images

    Image Field put() silently compresses jpg images

    The put() method of the ImageGridFsProxy opens and saves images before storing them to gridfs. During saving of the image, as Image.save() is used without keyword arguments the default behavior for .jpg is a quality value of 75, as per Pillow documentation .
    This leads to saving a significantly changed (compressed/ reduced quality compressed) version of the image. In my specific case this divides file-size by more than 4 and reduces the image quality visibly which I don't imagine is expected or mentioned anywhere.
    I think this issue can be (relatively) easily sidestepped by duplicating the file before the Pillow operations and not saving with pillow at all but I might be missing something.

    opened by janmueck 2
  • Docker/compose for local development

    Docker/compose for local development

    Hi there! Long time mongoengine user, first time (potential) contributor here.

    I started poking around the tickets regarding transaction support and thought I might take a crack at that. When I forked & cloned, I didn't see any docker configurations for local development.

    Would there be any interest in that as an option for local development? Here's something I quickly whipped up in my fork that has passing tests, in case anyone is curious as to what the footprint of this addition might be: https://github.com/MongoEngine/mongoengine/compare/master...juannyG:local-docker

    opened by juannyG 1
Releases(v0.23.1)
  • v0.23.0(Mar 4, 2021)

  • v0.22.1(Dec 16, 2020)

  • v0.22.0(Dec 14, 2020)

  • v0.21.0(Nov 19, 2020)

  • v0.20.0(May 2, 2020)

  • v0.19.1(Jan 4, 2020)

  • v0.19.0(Dec 24, 2019)

  • v0.18.2(Jun 25, 2019)

  • v0.18.1(Jun 18, 2019)

  • v0.18.0(Jun 12, 2019)

  • v0.17.0(Mar 11, 2019)

  • v0.16.2(Nov 21, 2018)

  • v0.16.1(Nov 14, 2018)

  • v0.15.3(Jul 16, 2018)

  • v0.15.1(Apr 17, 2018)

  • v0.15.0(Apr 6, 2018)

  • v0.14.3(Oct 1, 2017)

  • v0.14.1(Oct 1, 2017)

    • Removed SemiStrictDict and started using a regular dict for BaseDocument._data #1630
    • Added support for the $position param in the $push operator #1566
    • Fixed DateTimeField interpreting an empty string as today #1533
    • Added a missing __ne__ method to the GridFSProxy class #1632
    • Fixed BaseQuerySet._fields_to_db_fields #1553
    Source code(tar.gz)
    Source code(zip)
  • v0.14.0(May 8, 2017)

    This release includes a few bug fixes and a significant code cleanup in an ongoing effort to make this codebase much healthier. Primary changes:

    • BREAKING CHANGE: Removed the coerce_types param from QuerySet.as_pymongo #1549
    • POTENTIAL BREAKING CHANGE: Made EmbeddedDocument not hashable by default #1528
    • Improved code quality #1531, #1540, #1541, #1547
    Source code(tar.gz)
    Source code(zip)
  • v0.13.0(Apr 16, 2017)

    This release adds UTF-8 support to the EmailField along with other validation tweaks (#1527).

    Previously, email addresses containing Unicode characters didn't work at all. Now, domains with Unicode characters are supported out of the box and similar validation on the user part can be explicitly enabled. Additionally, you can enable an optional validation of IP-based domain parts (e.g. "[email protected][127.0.0.1]"), and you can have a whitelist of otherwise invalid domains (e.g. "[email protected]").

    Source code(tar.gz)
    Source code(zip)
  • v0.12.0(Apr 7, 2017)

    This is primarily a bugfix release, but it may also introduce breaking changes if you relied on a previously broken implementation. See https://mongoengine-odm.readthedocs.io/upgrade.html before upgrading.

    • POTENTIAL BREAKING CHANGE: Fixed limit/skip/hint/batch_size chaining #1476
    • POTENTIAL BREAKING CHANGE: Changed a public QuerySet.clone_into method to a private QuerySet._clone_into #1476
    • Fixed the way Document.objects.create works with duplicate IDs #1485
    • Fixed connecting to a replica set with PyMongo 2.x #1436
    • Fixed using sets in field choices #1481
    • Fixed deleting items from a ListField #1318
    • Fixed an obscure error message when filtering by field__in=non_iterable. #1237
    • Fixed behavior of a dec update operator #1450
    • Added a rename update operator #1454
    • Added validation for the db_field parameter #1448
    • Fixed the error message displayed when querying an EmbeddedDocumentField by an invalid value #1440
    • Fixed the error message displayed when validating unicode URLs #1486
    • Raise an error when trying to save an abstract document #1449
    Source code(tar.gz)
    Source code(zip)
  • v0.11.0(Dec 13, 2016)

    This release includes a major re-haul of MongoEngine's code quality and introduces a few breaking changes. It also touches many different parts of the package and although all the changes have been tested and scrutinized, you're encouraged to thoroughly test the upgrade.

    First breaking change involves renaming ConnectionError to MongoEngineConnectionError. If you import or catch this exception, you'll need to rename it in your code.

    Second breaking change drops Python v2.6 support. If you run MongoEngine on that Python version, you'll need to upgrade it first.

    Third breaking change drops an old backward compatibility measure where from mongoengine.base import ErrorClass would work on top of from mongoengine.errors import ErrorClass (where ErrorClass is e.g. ValidationError). If you import any exceptions from mongoengine.base, change it to mongoengine.errors.

    Lastly, we fixed absent rounding for DecimalField when force_string is set (#1103).

    Source code(tar.gz)
    Source code(zip)
  • v0.10.9(Dec 11, 2016)

  • v0.10.8(Dec 11, 2016)

    • Added support for QuerySet.batch_size #1426
    • Fixed query set iteration within iteration #1427
    • Fixed an issue where specifying a MongoDB URI host would override more information than it should #1421
    • Added ability to filter the generic reference field by ObjectId and DBRef #1425
    • Fixed delete cascade for models with a custom primary key field #1247
    • Added ability to specify an authentication mechanism (e.g. X.509) #1333
    • Added support for falsey primary keys (e.g. doc.pk = 0) #1354
    • Fixed QuerySet#sum/average for fields w/ explicit db_field #1417
    • Fixed filtering by embedded_doc=None #1422
    • Added support for cursor.comment #1420
    • Fixed doc.get__display #1419
    • Fixed repr method of the StrictDict #1424
    • Added a deprecation warning for Python 2.6
    Source code(tar.gz)
    Source code(zip)
  • v0.10.7(Nov 29, 2016)

    • Dropped Python 3.2 support #1390
    • Fixed the bug where dynamic doc has index inside a dict field #1278
    • Fixed: ListField minus index assignment does not work #1128
    • Fixed cascade delete mixing among collections #1224
    • Add signal_kwargs argument to Document.save, Document.delete and BaseQuerySet.insert to be passed to signals calls #1206
    • Raise OperationError when trying to do a drop_collection on document with no collection set.
    • count on ListField of EmbeddedDocumentField fails. #1187
    • Fixed long fields stored as int32 in Python 3. #1253
    • MapField now handles unicodes keys correctly. #1267
    • ListField now handles negative indicies correctly. #1270
    • Fixed AttributeError when initializing EmbeddedDocument with positional args. #681
    • Fixed no_cursor_timeout error with pymongo 3.0+ #1304
    • Replaced map-reduce based QuerySet.sum/average with aggregation-based implementations #1336
    • Fixed support for __ to escape field names that match operators names in update #1351
    • Fixed BaseDocument#_mark_as_changed #1369
    • Added support for pickling QuerySet instances. #1397
    • Fixed connecting to a list of hosts #1389
    • Fixed a bug where accessing broken references wouldn't raise a DoesNotExist error #1334
    • Fixed not being able to specify use_db_field=False on ListField(EmbeddedDocumentField) instances #1218
    • Improvements to the dictionary fields docs #1383
    Source code(tar.gz)
    Source code(zip)
  • v0.10.6(Jan 25, 2016)

    • Add support for mocking MongoEngine based on mongomock. #1151
    • Fixed not being able to run tests on Windows. #1153
    • Allow creation of sparse compound indexes. #1114
    Source code(tar.gz)
    Source code(zip)
  • v0.10.5(Nov 30, 2015)

Micro ODM for MongoDB

Beanie - is an asynchronous ODM for MongoDB, based on Motor and Pydantic. It uses an abstraction over Pydantic models and Motor collections to work wi

Roman 275 Oct 15, 2021
Async ODM (Object Document Mapper) for MongoDB based on python type hints

ODMantic Documentation: https://art049.github.io/odmantic/ Asynchronous ODM(Object Document Mapper) for MongoDB based on standard python type hints. I

Arthur Pastel 412 Oct 22, 2021
A Pythonic, object-oriented interface for working with MongoDB.

PyMODM MongoDB has paused the development of PyMODM. If there are any users who want to take over and maintain this project, or if you just have quest

mongodb 330 Oct 16, 2021
A Python Object-Document-Mapper for working with MongoDB

MongoEngine Info: MongoEngine is an ORM-like layer on top of PyMongo. Repository: https://github.com/MongoEngine/mongoengine Author: Harry Marr (http:

MongoEngine 3.6k Oct 23, 2021
PyMongo - the Python driver for MongoDB

PyMongo Info: See the mongo site for more information. See GitHub for the latest source. Documentation: Available at pymongo.readthedocs.io Author: Mi

mongodb 3.4k Oct 25, 2021
MongoDB data stream pipeline tools by YouGov (adopted from MongoDB)

mongo-connector The mongo-connector project originated as a MongoDB mongo-labs project and is now community-maintained under the custody of YouGov, Pl

YouGov 1.8k Oct 25, 2021
Motor - the async Python driver for MongoDB and Tornado or asyncio

Motor Info: Motor is a full-featured, non-blocking MongoDB driver for Python Tornado and asyncio applications. Documentation: Available at motor.readt

mongodb 1.8k Oct 21, 2021
Motor - the async Python driver for MongoDB and Tornado or asyncio

Motor Info: Motor is a full-featured, non-blocking MongoDB driver for Python Tornado and asyncio applications. Documentation: Available at motor.readt

mongodb 1.6k Feb 6, 2021
Pony Object Relational Mapper

Downloads Pony Object-Relational Mapper Pony is an advanced object-relational mapper. The most interesting feature of Pony is its ability to write que

null 2.7k Oct 25, 2021
Monty, Mongo tinified. MongoDB implemented in Python !

Monty, Mongo tinified. MongoDB implemented in Python ! Inspired by TinyDB and it's extension TinyMongo. MontyDB is: A tiny version of MongoDB, against

David Lai 443 Oct 20, 2021
sync/async MongoDB ODM, yes.

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

Scille 374 Oct 16, 2021
DataStax Python Driver for Apache Cassandra

DataStax Driver for Apache Cassandra A modern, feature-rich and highly-tunable Python client library for Apache Cassandra (2.1+) and DataStax Enterpri

DataStax 1.3k Oct 19, 2021
Toolkit for storing files and attachments in web applications

DEPOT - File Storage Made Easy DEPOT is a framework for easily storing and serving files in web applications on Python2.6+ and Python3.2+. DEPOT suppo

Alessandro Molina 128 Sep 21, 2021
A simple password manager I typed with python using MongoDB .

Python with MongoDB A simple python code example using MongoDB. How do i run this code • First of all you need to have a python on your computer. If y

null 6 Aug 15, 2021
The Database Toolkit for Python

SQLAlchemy The Python SQL Toolkit and Object Relational Mapper Introduction SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that giv

SQLAlchemy 4.4k Oct 24, 2021
Familiar asyncio ORM for python, built with relations in mind

Tortoise ORM Introduction Tortoise ORM is an easy-to-use asyncio ORM (Object Relational Mapper) inspired by Django. Tortoise ORM was build with relati

Tortoise 2.4k Oct 23, 2021
Python DBAPI simplified

Facata A Python library that provides a simplified alternative to DBAPI 2. It provides a facade in front of DBAPI 2 drivers. Table of Contents Install

Tony Locke 41 Sep 19, 2021
Redis Python Client

redis-py The Python interface to the Redis key-value store. Python 2 Compatibility Note redis-py 3.5.x will be the last version of redis-py that suppo

Andy McCurdy 9.7k Oct 23, 2021
Google Sheets Python API v4

pygsheets - Google Spreadsheets Python API v4 A simple, intuitive library for google sheets which gets your work done. Features: Open, create, delete

Nithin Murali 1.2k Oct 22, 2021