Switch to MariaDB connector and Create UserManager Class
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user