Python MongoDB - Introduction



Pymongo is a python distribution which provides tools to work with MongoDB, it is the most preferred way to communicate with MongoDB database from python.

Installation

To install pymongo first of all make sure you have installed python3 (along with PIP) and MongoDB properly. Then execute the following command.

(myenv) D:\Projects\python\myenv>pip3 install pymongo
Requirement already satisfied: pymongo in .\Lib\site-packages (4.16.0)
Requirement already satisfied: dnspython3.0.0>=2.6.1 in .\Lib\site-packages (from pymongo) (2.8.0)

Verification

Once you have installed pymongo, open a new text document, paste the following line in it and, save it as test.py.

test.py

import pymongo

If you have installed pymongo properly, if you execute the test.py as shown below, you should not get any issues.

(myenv) D:\Projects\python\myenv>py test.py
(myenv) D:\Projects\python\myenv>
Advertisements