|
@@ -58,15 +58,15 @@ class AsyncMySQLClient(object):
|
|
:param sql:
|
|
:param sql:
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- async with self.mysql_pool.acquire() as coon:
|
|
|
|
- async with coon.cursor() as cursor:
|
|
|
|
|
|
+ async with self.mysql_pool.acquire() as conn:
|
|
|
|
+ async with conn.cursor() as cursor:
|
|
try:
|
|
try:
|
|
await cursor.execute(sql, params)
|
|
await cursor.execute(sql, params)
|
|
affected_rows = cursor.rowcount
|
|
affected_rows = cursor.rowcount
|
|
- await coon.commit()
|
|
|
|
|
|
+ await conn.commit()
|
|
return affected_rows
|
|
return affected_rows
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- await coon.rollback()
|
|
|
|
|
|
+ await conn.rollback()
|
|
raise
|
|
raise
|
|
|
|
|
|
async def async_insert_many(self, sql, params_list):
|
|
async def async_insert_many(self, sql, params_list):
|
|
@@ -75,15 +75,15 @@ class AsyncMySQLClient(object):
|
|
:param params_list:
|
|
:param params_list:
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- async with self.mysql_pool.acquire() as coon:
|
|
|
|
- async with coon.cursor() as cursor:
|
|
|
|
|
|
+ async with self.mysql_pool.acquire() as conn:
|
|
|
|
+ async with conn.cursor() as cursor:
|
|
try:
|
|
try:
|
|
await cursor.executemany(sql, params_list)
|
|
await cursor.executemany(sql, params_list)
|
|
affected_rows = cursor.rowcount
|
|
affected_rows = cursor.rowcount
|
|
- await coon.commit()
|
|
|
|
|
|
+ await conn.commit()
|
|
return affected_rows
|
|
return affected_rows
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- await coon.rollback()
|
|
|
|
|
|
+ await conn.rollback()
|
|
raise
|
|
raise
|
|
|
|
|
|
async def __aenter__(self):
|
|
async def __aenter__(self):
|
|
@@ -145,7 +145,7 @@ class TaskMySQLClient(object):
|
|
:param sql:
|
|
:param sql:
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- async with self.mysql_pool.acquire() as coon:
|
|
|
|
- async with coon.cursor() as cursor:
|
|
|
|
|
|
+ async with self.mysql_pool.acquire() as conn:
|
|
|
|
+ async with conn.cursor() as cursor:
|
|
await cursor.execute(sql, params)
|
|
await cursor.execute(sql, params)
|
|
- await coon.commit()
|
|
|
|
|
|
+ await conn.commit()
|