manage_sql.py: sql_checkcon() was the same funcion as conn()
This commit is contained in:
parent
5e68a9f7be
commit
3b38eae5e3
|
@ -36,16 +36,6 @@ SQL_PWD = CONFIG.get('sql', 'passwd')
|
||||||
class HandleSql:
|
class HandleSql:
|
||||||
"""Class to handle sql connection."""
|
"""Class to handle sql connection."""
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def sql_checkconn():
|
|
||||||
"""Check MySQL 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
|
@staticmethod
|
||||||
def sql_conn():
|
def sql_conn():
|
||||||
"""Init sql connection."""
|
"""Init sql connection."""
|
||||||
|
|
4
test.py
4
test.py
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
from manage_sql.manage_sql import HandleSql
|
from manage_sql.manage_sql import HandleSql
|
||||||
|
|
||||||
MY_SQL_CONN = HandleSql()
|
MYSQL_CONN = HandleSql()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
check_return_bdd = MY_SQL_CONN.sql_checkcon()
|
check_return_bdd = MYSQL_CONN.conn()
|
||||||
except OperationalError as error:
|
except OperationalError as error:
|
||||||
print(error)
|
print(error)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue