我正在使用aiomysql和MariaDB。我可以创建表或选择数据,但不能将数据插入表中。如果您SELECT
使用 数据fetchall()
,那么它将显示您刚刚插入的内容,但会立即从数据库中删除。
async def test_example(loop):
pool = await aiomysql.create_pool(host='127.0.0.1', port=3306,
user='root', password='',
db='test', loop=loop)
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("INSERT INTO `tbl`(`id`, `val`) VALUES (37, 'z');")
print(cur.fetchall())
pool.close()
await pool.wait_closed()
loop = asyncio.get_event_loop()
loop.run_until_complete(test_example(loop))
为什么?