This example will connect to the MongoDB running at localhost
(on the default port 27017
) without any username or password and open the database named mydb
from pymongo import MongoClient client = MongoClient("mongodb://localhost") db = client["mydb"]