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.