Home / Python MongoDB / How to Create a MongoDB Database in Python In this example we will show how to create a MongoDB database in Python. Source Code from pymongo import MongoClient client = MongoClient("localhost", 27017) db = client["mydatabase"]