|
|
@@ -156,6 +156,17 @@ class OfpayHelper:
|
|
|
break;
|
|
|
self.db_conn = db_conn;
|
|
|
|
|
|
+ def check_mysql_connect(self):
|
|
|
+ try:
|
|
|
+ with self.db_conn.cursor() as cursor:
|
|
|
+ cursor.execute('SELECT 1');
|
|
|
+ except pymysql.MySQLError as e:
|
|
|
+ print(e);
|
|
|
+ self.db_conn.close();
|
|
|
+ print('mysql重连...');
|
|
|
+ self.connect_mysql();
|
|
|
+
|
|
|
+
|
|
|
def check_host_pass(self, host):
|
|
|
if self.host_ip:
|
|
|
if host != self.host_ip and host != self.domain_name:
|
|
|
@@ -239,7 +250,12 @@ class OfpayHelper:
|
|
|
CALL UpdateElifeAccountData(%s, %s, %s, %s, %s, %s, %s, %s, %s);
|
|
|
''';
|
|
|
sql_params = (account, uuid, authorization, repr(cookies), user_agent, market_id, event_visitor_id, capture_code , update_time);
|
|
|
- cursor = self.db_conn.cursor();
|
|
|
- cursor.execute(sql_query, sql_params);
|
|
|
- self.db_conn.commit();
|
|
|
- cursor.close();
|
|
|
+
|
|
|
+ try:
|
|
|
+ self.check_mysql_connect();
|
|
|
+ cursor = self.db_conn.cursor();
|
|
|
+ cursor.execute(sql_query, sql_params);
|
|
|
+ self.db_conn.commit();
|
|
|
+ cursor.close();
|
|
|
+ except pymysql.OperationalError as e:
|
|
|
+ print(e);
|