It is extremely useful to have a generic connection class available that can be used throughout the application. This class needs to have the following capabilities:
- Accept a database connection string, which can be provided by a separate config file.
- Create a connection to a database.
- Create a connection to a collection.
First, we must discuss the role of the pymongo.MongoClient class.