What is the relationship between flask, mongokit, pymongo, flask-pymongo?

荒凉一梦 提交于 2019-12-10 10:01:26

问题


I am really new to Flask and MongoDB. I read the Flask documentation about MongoDB, and turns out I felt so confused that I did not know which one I need to install.

In Flask document, it says if you want to operate MongoDB, you should install Mongokit, yes I did, I build the user structure like document said, and save it, but it did not work, I look up into MongoDB shell, nothing stored there. So, i keep searching that I need Pymongo, and another document say that Flask-PyMongo is the bridge between MongoDB and Pymongo.

do I need to install all of them? what's their relationship, I need someone clear my head a little bit BTW, can I use SQLalchemy with MongoDB? or I just use Mongokit whatever above.


回答1:


From MongoKit documentation:

MongoKit is based on pymongo. As such, all of the pymongo API is exposed through MongoKit. If you don't find what you want in the MongoKit API, please take a look at pymongo's documenation. All the pymongo API is exposed via connection, database and collection so Connection, Database and Collection are wrappers around pymongo objects.

MongoKit is an Object Document Mapper (ODM)

And as specify here

MongoKit is a python module that brings a structured schema and validation layer on top of the great pymongo driver.

As mentioned in Flask-PyMongo documentation

Flask-PyMongo bridges Flask and PyMongo, so that you can use Flask’s normal mechanisms to configure and connect to MongoDB.

Now:

Do I need to install all of them?

The answer is NO you can use either MongoKit or Flask-PyMongo

Can I use SQLalchemy with Mongodb?

The answer is NO Why? read this



来源:https://stackoverflow.com/questions/29202710/what-is-the-relationship-between-flask-mongokit-pymongo-flask-pymongo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!