Get startedGet started for free

Connecting to a MongoDB server

To get started you need to connect to a MongoDB server from inside Python. The pymongo package provides the MongoClient for this.

This exercise is part of the course

Introduction to MongoDB in Python

View Course

Exercise instructions

  • From the pymongo package, import MongoClient so you can use it.
  • Create a MongoClient instance and store it in a variable client.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import MongoClient
from ____ import ____ 

# Create client
client = ____
Edit and Run Code