I'm new to PyMongo and Flask, I have completed the tutorial for flask though and feel rather comfortable with it. I am now trying to implement a flask server with MongoDb and I'm not sure how to progress.
I see there are two libraries, PyMongo and Flask-PyMongo. It's isn't clear to me which I should use, or if I need to use both. How they interoperate and such...
First, i'm trying to connect to a mongodb, I have that running in the background and I can see connections whenever I start up my flask server, so that must be working. PyMongo offers methods to connect to specific database using db = client['test-database']
. Flask-pymongo seems to just give a db connection from nowhere when using mongo = PyMongo(app)
then mongo.db
for access to the db.
Being new to mongo as well this is all confusing for me, I was hoping someone would be able to give me a clear answer to all my questions, searches around the web don't reveal many results for flask-pymongo library.
I did have a look at this question: What is the relationship between flask, mongokit, pymongo, flask-pymongo?, but it did not clear anything up for me.
flask-*
modules compared to their "standard" module. They are generally speaking, a wrapper around the core module that makes them interact Flask a little better. For exampleflask-sqlalchemy
will still install normalSQLAlchemy
and the API is slightly different but underneath it's all working approximately the same.PyMongo
andFlask-PyMongo
thrown at me. Thanks to your help I now have a direction to go in at least, I will aim to read some PyMongo documentation then move onto Flask-PyMongo, I think the wrapper will be easier to understand if I know the background first.Flask-PyMongo depends, and will install for you, recent versions of Flask (0.8 or later) and PyMongo (2.4 or later)
.