Forgot to give an example of the code I use
# Get the MongoDB credentials from the config file
cparser = ConfigParser()
cparser.read(self.config)
USERNAME = quote_plus(cparser["MONGODB"]["USERNAME"])
PASSWORD = quote_plus(cparser["MONGODB"]["PASSWORD"])
CLUSTER = cparser["MONGODB"]["CLUSTER"]
# Preparing the database URL
uri = f'mongodb+srv://{USERNAME}:{PASSWORD}@{CLUSTER}/test?authSource=admin&replicaSet=atlas-itbq89-shard-0&readPreference=primary&ssl=true'
# Connecting to the MongoDB database
self.client = MongoClient(uri)