Skip to content

Commit

Permalink
refact(db): rename database parameters names
Browse files Browse the repository at this point in the history
  • Loading branch information
ZRunner committed Feb 6, 2024
1 parent f03412e commit 165fdac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions libs/boot_utils/load_sql_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ def load_sql_connection(bot: "Axobot"):
user=bot.database_keys['user'],
password=bot.database_keys['password'],
host="127.0.0.1",
database=bot.database_keys['database1']
database=bot.database_keys['name_main'],
connection_timeout=5
)
except (mysql_errors.InterfaceError, mysql_errors.ProgrammingError, mysql_errors.DatabaseError):
bot.log.warning("Unable to access local dabatase - attempt via IP")
cnx = mysql.connector.connect(
user=bot.database_keys['user'],
password=bot.database_keys['password'],
host=bot.database_keys['host'],
database=bot.database_keys['database1'],
database=bot.database_keys['name_main'],
connection_timeout=5
)
bot.log.info("Database connected remotely")
Expand Down
18 changes: 12 additions & 6 deletions libs/bot_classes/axobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,16 @@ def connect_database_axobot(self):
if len(self.database_keys) > 0:
if self._cnx[0][0] is not None:
self._cnx[0][0].close()
self.log.debug('Connecting to MySQL (user %s, database "%s")',
self.database_keys['user'], self.database_keys['database1'])
self.log.debug(
'Connecting to MySQL (user %s, database "%s")',
self.database_keys['user'],
self.database_keys['name_main']
)
self._cnx[0][0] = sql_connect(
user=self.database_keys['user'],
password=self.database_keys['password'],
host=self.database_keys['host'],
database=self.database_keys['database1'],
database=self.database_keys['name_main'],
buffered=True,
charset='utf8mb4',
collation='utf8mb4_unicode_ci',
Expand Down Expand Up @@ -252,13 +255,16 @@ def connect_database_xp(self):
if len(self.database_keys) > 0:
if self._cnx[1][0] is not None:
self._cnx[1][0].close()
self.log.debug('Connecting to MySQL (user %s, database "%s")',
self.database_keys['user'], self.database_keys['database2'])
self.log.debug(
'Connecting to MySQL (user %s, database "%s")',
self.database_keys['user'],
self.database_keys['name_xp']
)
self._cnx[1][0] = sql_connect(
user=self.database_keys['user'],
password=self.database_keys['password'],
host=self.database_keys['host'],
database=self.database_keys['database2'],
database=self.database_keys['name_xp'],
buffered=True,
connection_timeout=5
)
Expand Down

0 comments on commit 165fdac

Please sign in to comment.