|
@@ -46,7 +46,7 @@ class TidbConn:
|
|
@classmethod
|
|
@classmethod
|
|
def quary(cls, sql):
|
|
def quary(cls, sql):
|
|
mysql_conn = TidbConn.get_connection()
|
|
mysql_conn = TidbConn.get_connection()
|
|
- TidbConn._reConn(mysql_conn)
|
|
|
|
|
|
+ TidbConn._reConn()
|
|
cur = mysql_conn.cursor()
|
|
cur = mysql_conn.cursor()
|
|
cur.execute(sql)
|
|
cur.execute(sql)
|
|
result = cur.fetchall()
|
|
result = cur.fetchall()
|
|
@@ -74,7 +74,7 @@ class TidbConn:
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
def upsert(conn, sql_buff):
|
|
def upsert(conn, sql_buff):
|
|
- TidbConn._reConn(conn)
|
|
|
|
|
|
+ TidbConn._reConn()
|
|
try:
|
|
try:
|
|
TidbConn.exec_sql(conn, sql_buff)
|
|
TidbConn.exec_sql(conn, sql_buff)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -82,15 +82,15 @@ class TidbConn:
|
|
TidbConn.get_connection().commit()
|
|
TidbConn.get_connection().commit()
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
- def _reCon(cls, conn):
|
|
|
|
|
|
+ def _reCon(cls):
|
|
""" MySQLdb.OperationalError异常"""
|
|
""" MySQLdb.OperationalError异常"""
|
|
# self.con.close()
|
|
# self.con.close()
|
|
while True:
|
|
while True:
|
|
try:
|
|
try:
|
|
- conn.ping()
|
|
|
|
|
|
+ TidbConn.get_connection().ping()
|
|
break
|
|
break
|
|
except OperationalError:
|
|
except OperationalError:
|
|
- conn.ping(True)
|
|
|
|
|
|
+ TidbConn.get_connection().ping(True)
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|