Einloggen funktioniert
This commit is contained in:
@@ -7,20 +7,25 @@ class DbManager(object):
|
||||
__dbmanager = None
|
||||
|
||||
def __new__(cls, dbconf = None):
|
||||
|
||||
if cls.__dbmanager is None:
|
||||
cls.__dbmanager = super(DbManager, cls).__new__(cls)
|
||||
cls.__dbmanager.__initializeConfig(dbconf)
|
||||
|
||||
return cls.__dbmanager
|
||||
|
||||
def getConnection(cls):
|
||||
if not cls.__connection:
|
||||
try:
|
||||
cls.__connection = mariadb.connect(**cls.__con_param)
|
||||
|
||||
def getConnection(cls):
|
||||
try:
|
||||
if not cls.__connection or not cls.__connection.ping():
|
||||
cls.__connection = mariadb.connect(**cls.__con_param)
|
||||
except mariadb.InterfaceError as e:
|
||||
cls.__connection = mariadb.connect(**cls.__con_param)
|
||||
print(f"INTERFACE ERROR: {e}")
|
||||
except mariadb.Error as e:
|
||||
print("Connection parameters are wrong: {e}")
|
||||
return cls.__connection
|
||||
print(f"Connection parameters are wrong: {e}")
|
||||
|
||||
return cls.__connection
|
||||
|
||||
def __initializeConfig(cls, dbconf):
|
||||
cls.__con_param = { 'user': dbconf['DB_USER'], 'password': dbconf['DB_PASS'],
|
||||
@@ -30,3 +35,5 @@ class DbManager(object):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user