Skip to content

v0.2.0

Compare
Choose a tag to compare
@Vastxiao Vastxiao released this 15 Oct 13:20
· 13 commits to main since this release
4bae067

What's Changed

Features

  1. Fixed the handling of the echo parameter in aiomysql.
  2. 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

  1. 修复aiomysql对echo参数的处理。
  2. 对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)