'Executing multiple SQL queries using aiomysql

I'm trying to execute multiple queries through aiomysql. Here is the sample program.:

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())

I'm getting the following error:

    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'

Am I missing anything here? It seems like multi=True support is missing.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source