What's Changed
Features
- Fixed the handling of the
echo
parameter in aiomysql
.
- Added the
echo_sql_log
parameter to the AsMysql
class, used to control whether aiomysql
outputs the executed SQL statements (default is False).
from asmysql import AsMysql
class TestAsMysql(AsMysql):
# This allows controlling whether the executed SQL statements in aiomysql
# are output to Logging.logger.
echo_sql_log = True
# Of course, the `echo_sql_log` parameter can also be passed when instantiating AsMysql.
async def main():
async with TestAsMysql(echo_sql_log=True) as mysql:
result = await mysql.client.execute('select user, authentication_string, host from mysql.user')
if result.err:
print(result.err)
else:
async for item in result.iterate():
print(item)
Features
- 修复aiomysql对echo参数的处理。
- 对AsMysql类新增echo_sql_log参数,用于控制aiomysql是否输出执行的sql语句(默认False)。
from asmysql import AsMysql
class TestAsMysql(AsMysql):
# 这样就可以控制aiomysql库是否在Logging.logger输出执行的sql语句。
echo_sql_log = True
# 当然,echo_sql_log参数也可以在实例化AsMysql时传入。
async def main():
async with TestAsMysql(echo_sql_log=True) as mysql:
result = await mysql.client.execute('select user,authentication_string,host from mysql.user')
if result.err:
print(result.err)
else:
async for item in result.iterate():
print(item)