PyMongo is a Python connector tools for working with MongoDB
Install pymongo
sachin@bd:~$ pip3 install pymongo
Collecting pymongo
Downloading https://files.pythonhosted.org/packages/fb/4a/586826433281ca285f0201235fccf63cc29a30fa78bcd72b6a34e365972d/pymongo-3.8.0-cp36-cp36m-manylinux1_x86_64.whl (416kB)
100% |████████████████████████████████| 419kB 568kB/s
Installing collected packages: pymongo
Successfully installed pymongo-3.8.0
Connect MongoDB
>>python3 //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 >