Video Transcript (English)
In this unit, you learned what a MongoDB driver is and how to connect a Python application to a MongoDB Atlas cluster by using PyMongo. You also learned how to resolve common connection errors.
When we build a Python application that connects to MongoDB, the application requires a set of libraries to interact with our MongoDB instance.
These libraries are referred to as drivers.
Drivers are the middleware between your application and your database.
PyMongo is the official MongoDB driver for synchronous Python applications.
Before we connected our application to our Atlas cluster, we first had to install PyMongo by using pip, the package installer for Python.
After installing the driver, we used our Atlas connection string to create a connection between our application and database.
We learned the importance of using a single MongoClient instance for the life of the application, to be reused across all database requests.
Creating MongoClients is resource intensive. Creating a new one for each database request will degrade the application’s performance.
Finally, you learned how to troubleshoot common connection issues such as: Network access errors and user authentication errors.
This knowledge gives you the foundation to troubleshoot the most common connection issues.
Interested in next steps now that you can connect your database to your Python application? Try implementing CRUD methods and performing aggregations by using PyMongo.
To do this, check out our units on these topics, or refer to the MongoDB documentation.
Congratulations on completing this unit. Until next time, keep coding!