PyMongo is a Python connector tools for working with MongoDB

Install pymongo

sachin@bd:~$ pip3 install pymongo
Collecting pymongo
 Downloading (416kB)
    100% |████████████████████████████████| 419kB 568kB/s
Installing collected packages: pymongo
Successfully installed pymongo-3.8.0

Connect MongoDB

//Import pymongo package
>>> import pymongo

//connection string to connect mongoDB
//loclhost : hostname , 27017: port where database running
>>> conn_string = pymongo.MongoClient("mongodb://localhost:27017")

//List all databases available in MongoDB
>>> conn_string.list_database_names()
['admin', 'config', 'local']

verify with MongoDb

sachin@bd:~$ mongo
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB