From 0e3e3d2cc3fc1809345c284b0e7165682fcf0471 Mon Sep 17 00:00:00 2001 From: DeveloperAnonymous <40847862+DeveloperAnonymous@users.noreply.github.com> Date: Thu, 23 Mar 2023 18:00:09 -0400 Subject: [PATCH] Updated DB connection to work with Atlas --- base_configs.py | 1 - bot/db/services/base_service.py | 8 ++++---- requirements.txt | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/base_configs.py b/base_configs.py index 8d1337e..ce1e8b5 100644 --- a/base_configs.py +++ b/base_configs.py @@ -8,7 +8,6 @@ # Database Configs DB_HOST = "localhost" -DB_PORT = 27017 DB_NAME = "database_name" DB_USER = "Cool Name" DB_PASSWORD = "Secure Password" diff --git a/bot/db/services/base_service.py b/bot/db/services/base_service.py index 1f6e17a..37d08e9 100644 --- a/bot/db/services/base_service.py +++ b/bot/db/services/base_service.py @@ -42,10 +42,10 @@ def conn(self) -> Database: """Return a connection to the database.""" if self.__conn is None: self.__conn = MongoClient( - host=configs.DB_HOST, - username=configs.DB_USER, - password=configs.DB_PASSWORD, - authMechanism="SCRAM-SHA-256", + "mongodb+srv://" + + f"{configs.DB_USER}:{configs.DB_PASSWORD}" + + f"@{configs.DB_HOST}/" + + "?retryWrites=true&w=majority&ssl=true", ).get_database(configs.DB_NAME) return self.__conn diff --git a/requirements.txt b/requirements.txt index 2a22850..3e2799f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ discord.py[speed] jsonpickle -pymongo +pymongo[srv] # Linter pylint