Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lightweight Mongodb ODM/ORM for Python

I'm looking for MondoDB Python ODM/ORM that takes the best from two worlds: ODM/ORM & ultra fast direct dictionary read.

In other words package shall comply with following requirements:

  1. Allows to define and enforce schema.
  2. Allows to validate fields.
  3. Allows to read objects directly from mongodb (no ODM/ORM overhead).
    • Collections/objects returned directly by pymongo can be accessed using ODM/ORM layer (w/o extra queries).
    • I would imagine some kind of lazy field added by pymongo driver to objects that provides access to ORM juice (pymongo allows for such extensions).
    • Imagine use case:
      • For fast read we go directly to driver,
      • For data entry we use full ODM/ORM functionality
  4. Geofields support
  5. GridFS support of normal files and images
  6. DBRef support
  7. Does not enforce any hidden, framework specific fields
  8. Will work with Flask :)
  9. Has forms framework.
    • Forms cover sublists/subdicts
    • Backbone based forms would be just awesome
  10. Creates backbone models, collections, validators based of python definition

I know that I'm asking for much but wouldn't it be awesome to have something like this :)

In fact question could be rephrased into: "Which of existing Python Mongodb ODM/ORMs (MongoKit, MongoEngine) could be easily extended this way."

like image 854
Munhitsu Avatar asked Apr 20 '12 19:04

Munhitsu


2 Answers

1st of all I'd love to have it as well.

Based on my research

Ming is a very promising mongo ODM driver: http://merciless.sourceforge.net/

MongoEngine is too big to adapt it for your requirements/usecase. Same for MongoKit.

There is some hope in micromongo: http://packages.python.org/micromongo

Could be a good starting point.

BTW: Hmmm... I don't know what you're writing but having forms and validators covered you can easily build admin interface and end-up having next generation Django. Good luck!

like image 87
Jan Łapsa Avatar answered Oct 04 '22 14:10

Jan Łapsa


Well if you take the theory of an ORM what you need is not an ORM, since MongoDB is not a relational database, so there's no mapping to relational entities to do.

I think you must to check the answer of this post to check wether the recommendations made are what you need, I personally use MongoDB + Python directly, because of the "nature" of both Mongo and Python.

Looking around I found this library that could help you mongoEngine. Is like Django ORM. You should check it.

like image 41
Omar Avatar answered Oct 04 '22 15:10

Omar