代码
`import asyncio
import aiomysql
settings = {
"host": "127.0.0.1",
"port": 3306,
"user": "root",
"password": "123456",
"db": "test",
}
async def main():
pool = await aiomysql.create_pool(
host=settings["host"],
port=settings["port"],
user=settings["user"],
password=settings["password"],
db=settings["db"],
)
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("SELECT id,user_name FROM user")
# print(cur.description)
data = await cur.fetchone()
print(data)
pool.close()
await pool.wait_closed()
if name == 'main':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())`