Switch to MariaDB connector and Create UserManager Class

This commit is contained in:
2024-11-26 16:40:00 +01:00
parent 12eb6cf2f4
commit 3df853b5c9
12 changed files with 1169 additions and 46 deletions

View File

@@ -1,5 +1,5 @@
# This Python file uses the following encoding: utf-8
import mysql.connector
import mariadb
class DbManager(object):
__connection = None
@@ -14,6 +14,12 @@ class DbManager(object):
return cls.__dbmanager
def getConnection(cls):
if not cls.__connection:
try:
cls.__connection = mariadb.connect(**cls.__con_param)
except mariadb.Error as e:
print("Connection parameters are wrong: {e}")
return cls.__connection
def __initializeConfig(cls, dbconf):
@@ -21,6 +27,6 @@ class DbManager(object):
'port': int (dbconf['DB_PORT']), 'host': dbconf['DB_HOST'],
'database': dbconf['DB_NAME']
}
cls.__connection = mysql.connector.connect(**cls.__con_param)