Which Python API should be used with Mongo DB and Django

I am going back and forth over which the Python API should be used when interacting with Mongo. I did a quick overview of the landscape and identified the three leading candidates.

If you were developing a new content-heavy website using django , which API would you choose and why?

MongoEngine looks like it was built specifically for Django. PyMongo seems like a thin wrap around Mongo. He has great power, although he loses a lot of the abstractions obtained using django as a basis. Ming is an interesting intermediate point between PyMongo and MongoEngine, although I did not have the opportunity to take it for a test drive.

+46
python django mongodb
Apr 29 '10 at 21:18
source share
6 answers

As Mike says, you cannot escape PyMongo - all other interfaces are built on top of it. These other interfaces may not be needed. ORMs, such as those used by Django, are useful when working with SQL because they reduce the complexity of creating SQL queries and schemas and analyze result sets into objects.

PyMongo, however, already has that covered requests go through a convenient and simple API, and the results obtained from MongoDB are already objects (well, in other words, in Python - with the same difference) by definition. If you feel that you really need to decorate your Mongo documents with Python objects, it's easy to add the SON manipulator to PyMongo. The best part about this approach is that you can write code directly in PyMongo and add additional features later without having to insert a new API between your code and PyMongo.

What is left? Schema creation and migration are somewhat useful, but ad-hoc is almost as easy - most likely, if you plan to use MongoDB, you still want to break out of the traditional SQL-style model. Also, if you had a fully Django-compatible ORM MongoDB, you could get some mileage. Something less than this, and you are likely to create work for yourself.

You will not regret using PyMongo directly.

One of the last options worthy of attention if you are interested in maximum efficiency is the asynchronous version of PyMongo, here: http://github.com/fiorix/mongo-async-python-driver

+55
May 01 '10 at 7:02
source share
+11
Apr 30 '10 at 2:17
source share

Both MongoEngine and Ming depend on PyMongo - they just add some useful features on top of it. I would recommend at least starting with PyMongo directly - this way, if you decide to use one of the other tools and run into problems, it will be easy to understand what is happening โ€œunder the hoodโ€. However, I am very biased;).

+6
Apr 29 2018-10-22T00:
source share

You can try django-mongodb-engine to try. This is the backend for the Django-Nerel, so you can continue to use the Django and ORM models. This is not as complete as other APIs: http://www.allbuttonspressed.com/blog/django/2010/05/MongoDB-backend-for-Django-nonrel-released

+5
Jun 10 '10 at 21:47
source share

I just found "micromongo":

http://packages.python.org/micromongo/

He seems to add enough useful material on top of the pimongo without disturbing him.

+2
Jul 18 '11 at 15:31
source share

Take a look at djongo . It works by translating SQL queries to mongodb queries.

You do not need django-nonrel to run.

All the built-in modules of Django contrib (for example, admin, user, session) work without any changes.

MongoEngine requires you to rewrite Contrib modules and the last time I checked, the native administration module did not work on MongoEngine.

Existing models work without ORM translation.

0
Aug 17 '17 at 17:44 on
source share



All Articles