tursodatabase / libsql-experimental-python

libSQL API for Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support iterating a cursor for query results

CodingDoug opened this issue · comments

In sqlite3, this is the idiomatic way to iterate rows from a query:

con = sqlite3.connect(":memory:")
cur = con.cursor()
for row in cur.execute("SELECT * FROM users"):
    print(row)

execute just returns the same Cursor object, so this is equivalent:

con = sqlite3.connect(":memory:")
cur = con.cursor()
cur.execute("SELECT * FROM users")
for row in cur:
    print(row)

However, in libsql, this yields the error:

TypeError: 'builtins.Cursor' object is not iterable