Ver Fonte

2024-0627-处理mysql问题

罗俊辉 há 1 ano atrás
pai
commit
2834c9b19f
2 ficheiros alterados com 13 adições e 12 exclusões
  1. 1 1
      applications/deal/process_deal.py
  2. 12 11
      task.py

+ 1 - 1
applications/deal/process_deal.py

@@ -190,7 +190,7 @@ class ProcessDeal(object):
             SET 
                 content_status = %s
             WHERE 
-                trace_id = %s
+                trace_id = %s;
         """
         await self.mysql_client.async_insert(
             sql=update_sql,

+ 12 - 11
task.py

@@ -55,7 +55,7 @@ class TaskMySQLClient(object):
                 result = await cursor.fetchall()
                 return result
 
-    async def async_insert(self, sql):
+    async def async_insert(self, sql, params):
         """
         insert and update method
         :param sql:
@@ -63,7 +63,7 @@ class TaskMySQLClient(object):
         """
         async with self.mysql_pool.acquire() as coon:
             async with coon.cursor() as cursor:
-                await cursor.execute(sql)
+                await cursor.execute(sql, params)
                 await coon.commit()
 
 
@@ -90,12 +90,13 @@ async def main2():
 
 
 if __name__ == '__main__':
-    while True:
-        asyncio.run(main())
-        now_str = datetime.datetime.now().__str__()
-        print("{}    请求执行完成, 等待60s".format(now_str))
-        time.sleep(60)
-        asyncio.run(main2())
-        now_str = datetime.datetime.now().__str__()
-        print("查找历史数据{}    请求执行完成, 等待60s".format(now_str))
-        time.sleep(60)
+    asyncio.run(main())
+    # while True:
+    #     asyncio.run(main())
+    #     now_str = datetime.datetime.now().__str__()
+    #     print("{}    请求执行完成, 等待60s".format(now_str))
+    #     time.sleep(60)
+    #     asyncio.run(main2())
+    #     now_str = datetime.datetime.now().__str__()
+    #     print("查找历史数据{}    请求执行完成, 等待60s".format(now_str))
+    #     time.sleep(60)