[Python] Is there a way for automatic ODM for MongoDB in Python?

Discussão em 'Python' iniciado por Stack, Julho 12, 2025.

  1. Stack

    Stack Membro Participativo

    Is there any way to have out-of-the-box, automatic ODM for Python and MongoDB? For Java the MongoDB driver does everything: I can just dump object of my custom class and load it later, the driver does automatic type checking, mapping etc., I don't have to change anything in my code. Is this possible for Python and PyMongo, MongoEngine etc.? Something like:

    class MyClass:
    # definition

    obj = MyClass()
    db.save(obj) # automatically creates JSON
    obj = db.findOne({"name": "John Smith"})

    Continue reading...

Compartilhe esta Página