1import pymongo
2
3myclient = pymongo.MongoClient("mongodb://localhost:27017/")
4
5mydb = myclient["mypython"]
1# install the pymongo module through pip or some other package manager
2
3from pymongo import MongoClient
4
5client = MongoClient("<mongodb uri>")
6db = client.example_database # you can also do 'client["example_database"]'
7collection = db.example_collection
8
9for i in collection.find(): # returns a list of documents in the collection
10 print(i) # print collection document
11