Prerequisites
Prerequisites
To build and run this project, you will need:
Python 3.7 or higher
The
pymongo
moduleThe
dnspython
moduleAn 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
Open the
atlas-starter.py
file.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
At your command prompt, navigate to the
atlas_starter_python
directory.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!