我正在尝试通过 aiomysql 执行多个查询。这是示例程序:
import asyncio
import aiomysql
sql = '''
CREATE TABLE `mytable`( `id` ENUM('1') NOT NULL, `my_column` INT DEFAULT '200', PRIMARY KEY (`id`) );
INSERT INTO `mytable` (`my_column`) VALUES ('2');
'''
loop = asyncio.get_event_loop()
async def test_example():
conn = await aiomysql.connect(host=host,
user=user,
password=pwd,
db=database,
loop=loop)
cur = await conn.cursor()
for _ in await cur.execute(sql, multi=True):
pass
await conn.commit()
await cur.close()
conn.close()
loop.run_until_complete(test_example())
我收到以下错误:
python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "db_trial.py", line 25, in test_example
for _ in await cur.execute(sql, multi=True):
TypeError: execute() got an unexpected keyword argument 'multi'
我在这里错过了什么吗?似乎multi=True
缺少支持。