Introducing PyMongo

PyMongo is a library that implements drivers for MongoDB and will allow us to execute commands on our database from our application code. As usual, install it through pip using the following command (note that, similarly to MongoDB, you only need to install this library on the server):

pip install --user pymongo

Now, we can import this library into our application and build our real DBHelper class, implementing all the methods we used in our MockDBHelper class.

Writing the DBHelper class

The last class that we need is the DBHelper class, which will contain all the functions that are required for our application code to talk to our database. This class will use the pymongo library we just installed in order to run MongoDB commands. ...

Get Flask: Building Python Web Services now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.