All Collections
Python Development
Python Starter Project
Python Starter Project

This repository contains a basic example application built with the pymongo MongoDB Driver that connects to MongoDB Atlas.

Richa Deshpande avatar
Written by Richa Deshpande
Updated over a week ago

Prerequisites

To build and run this project, you will need:

  • Python 3.7 or higher

  • The pymongo module

  • The dnspython module

  • An Atlas account

1. Download the Repository

To get started with this sample project, download this repository to your programming environment. You can clone this project using Git version control:

git clone git@github.com:mongodb-university/atlas_starter_python.git

Or you can download the ZIP archive using your browser. If you download this project as a ZIP archive, unzip the archive before proceeding.

2. Install the pymongo driver

You can use pip to install the necessary Python modules.

pip install pymongo dnspython

3. Configure your Atlas Credentials

  1. Open the atlas-starter.py file.

  2. On line 8, replace the placeholder text with the connection string to your Atlas cluster.

client = pymongo.MongoClient( "mongodb+srv://<username>:<password>@<cluster-name>/test?retryWrites=true&w=majority")

4. Run the program

  1. At your command prompt, navigate to the atlas_starter_python directory.

  2. Run the program:

python atlas-starter.py

Assuming you have the correct connection string, you'll see the program output. Have fun modifying the code to experiment with pymongo and MongoDB!

Did this answer your question?