Compare commits
No commits in common. "master" and "master" have entirely different histories.
|
@ -17,7 +17,7 @@ import pymysql
|
|||
import sys
|
||||
|
||||
# Read conf.ini
|
||||
INI_CONF = "./config/mysql_conf.ini"
|
||||
INI_CONF = "./config/sql_conf.ini"
|
||||
|
||||
if os.path.exists(INI_CONF) is False:
|
||||
print("MySQL configuration error, {}: file not found".format(INI_CONF))
|
||||
|
@ -27,15 +27,25 @@ CONFIG = ConfigParser()
|
|||
CONFIG.read(INI_CONF)
|
||||
|
||||
# DB parameters
|
||||
SQL_HOST = CONFIG.get('mysql', 'host')
|
||||
SQL_DB = CONFIG.get('mysql', 'database')
|
||||
SQL_USER = CONFIG.get('mysql', 'user')
|
||||
SQL_PWD = CONFIG.get('mysql', 'passwd')
|
||||
SQL_HOST = CONFIG.get('sql', 'host')
|
||||
SQL_DB = CONFIG.get('sql', 'database')
|
||||
SQL_USER = CONFIG.get('sql', 'user')
|
||||
SQL_PWD = CONFIG.get('sql', 'passwd')
|
||||
|
||||
|
||||
class HandleSql:
|
||||
"""Class to handle sql connection."""
|
||||
|
||||
@staticmethod
|
||||
def sql_checkcon():
|
||||
"""Init sql connection."""
|
||||
try:
|
||||
global conn
|
||||
conn = pymysql.connect(host=SQL_HOST, db=SQL_DB, user=SQL_USER, passwd=SQL_PWD)
|
||||
cur = conn.cursor()
|
||||
except pymysql.DatabaseError as error:
|
||||
print(error)
|
||||
|
||||
@staticmethod
|
||||
def sql_conn():
|
||||
"""Init sql connection."""
|
||||
|
@ -43,7 +53,6 @@ class HandleSql:
|
|||
global conn
|
||||
conn = pymysql.connect(host=SQL_HOST, db=SQL_DB, user=SQL_USER, passwd=SQL_PWD)
|
||||
cur = conn.cursor()
|
||||
return True
|
||||
except pymysql.DatabaseError as error:
|
||||
print(error)
|
||||
|
Loading…
Reference in a new issue