omnilib/aiosqlite

How to make an iterdump

Closed this issue · 1 comments

1IxI1 commented

How to make an iterdump of async connection?

This works with original lib:

with sq.connect("cars.db") as con:
    cur = con.cursor()
 
    for sql in con.iterdump():
        print(sql)

and does not work with the async lib:

    for sql in con.iterdump():
TypeError: 'async_generator' object is not iterable

if add await then still does not work.

iterdump() provides an async generator, which needs to be used with the async for constructs, like:

async for sql in conn.iterdump():
    pass

or

dump = [sql async for sql in conn.iterdump()]

https://aiosqlite.omnilib.dev/en/stable/api.html#aiosqlite.Connection.iterdump