Python MongoDB

Python can be used in database applications.

MongoDB is one of the most popular NoSQL databases.

MongoDB

MongoDB stores data in documents similar to JSON, making the database very flexible and scalable.

In order to test the code examples in this tutorial, you need to access the MongoDB database.

You can find more information at https://www.mongodb.com Download the free MongoDB database.

PyMongo

Python requires the MongoDB driver to access the MongoDB database.

In this tutorial, we will use the MongoDB driver "PyMongo".

We recommend that you use PIP to install "PyMongo".

PIP is likely already installed in the Python environment.

Navigate to the location of PIP via the command line and then type the following:

Download and install "PyMongo":

C:\Users\...\AppData\Local\Programs\Python\Python36-32\Scripts>python -m pip install pymongo

Now you have downloaded and installed the mongoDB driver.

Test PyMongo

To test whether the installation is successful or if you have installed "pymongo", please create a Python page containing the following content:

demo_mongodb_test.py:

import pymongo

Run Example

If there are no errors when executing the above code, then "pymongo" is installed and ready.