PyMongo is a native Python driver for MongoDB.
pip install pymongo
Use MongoClient to create a connection. MongoClient defaults to MongoDB instance running on localhost:27017
if not specified.
from pymongo import MongoClient
client = MongoClient()
PyMongo's Database class represents database construct in MongoDB. Databases hold groups of logically related collections.
db = client.mydb
PyMongo's Collection class represents collection construct in MongoDB. Collections hold groups of related documents.
col = db.mycollection
MongoDB creates new databases and collections implicitly upon first use.