Anyone has experiences with MongoKit, MongoEngine or Flask-MongoAlchemy for Flask?
Which one do you prefer? Positive or negative experiences?. Too many options for a Flask-Newbie.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I have invested a lot of time evaluating the popular Python ORMs for MongoDB. This was an exhaustive exercise, as I really wanted to pick one.
My conclusion is that an ORM removes the fun out of MongoDB. None feels natural, they impose restrictions similar to the ones which made me move away from relational databases in the first place.
Again, I really wanted to use an ORM, but now I am convinced that using
pymongodirectly is the way to go. Now, I follow a pattern which embraces MongoDB,pymongo, and Python.A Resource Oriented Architecture leads to very natural representations. For instance, take the following User resource:
The
Resourcebase class looks likeNotice that I use the
WSGIspec directly, and leverageWerkzeugwhere possible (by the way, I think thatFlaskadds an unnecessary complication toWerkzeug).The function
representationtakes the request’sAcceptheaders, and produces a suitable representation (for example,application/json, ortext/html). It is not difficult to implement. It also adds theLast-Modifiedheader.Of course, your input needs to be sanitized, and the code, as presented, will not work (I mean it as an example, but it is not difficult to understand my point).
Again, I tried everything, but this architecture made my code flexible, simple, and extensible.