- Update the supported Python version range, with a minimum support of 3.9.
- Update the documentation content.
- Fixed the handling of the
echo
parameter inaiomysql
. - Added the
echo_sql_log
parameter to theAsMysql
class, used to control whetheraiomysql
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)
import asyncio
from asmysql import AsMysql
class TestAsMysql(AsMysql):
async def get_users(self):
result = await self.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)
async def main():
async with TestAsMysql() as mysql:
await mysql.get_users()
if __name__ == '__main__':
asyncio.run(main())
Added
Result.err_msg
to return a detailed string of the exception error.
asmysql
is a simplified wrapper library aroundaiomysql
.- Supports automatic management of MySQL connection pools and reconnection mechanism.
- Automatically captures and handles
MysqlError
globally.- Separates statement execution and data retrieval.
- Directly integrates the
AsMysql
class for logical development.
Initialized the project, with the development environment managed using
poetry
.