You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How to insert multiple rows without a traditional for loop?
Something like executemany in psycopg2
I am asking because I failed to find any example or method in the documentation.
Actually what I am doing is:
async def insertdemo(data, dns=DNS):
async with asyncpg.create_pool(dns) as pool:
async with pool.acquire() as con:
async with con.transaction():
stmt = '''insert into demo (num, name) select * from unnest($1::int[], $2::varchar[]);'''
await con.execute(stmt, *zip(*data))