Inserting rows while fetching(from another table) in SQLite

Posted by Samuel on Stack Overflow See other posts from Stack Overflow or by Samuel
Published on 2010-05-16T15:19:59Z Indexed on 2010/05/16 15:50 UTC
Read the original article Hit count: 242

Filed under:
|
|

I'm getting this error no matter what with python and sqlite.

  File "addbooks.py", line 77, in saveBook
  conn.commit()
  sqlite3.OperationalError: cannot commit transaction - SQL statements in progress

The code looks like this:

    conn = sqlite3.connect(fname)
cread = conn.cursor()

cread.execute('''select book_text from table''')
while True:
    row = cread.fetchone()
    if row is None:
        break
    ....
    for entry in getEntries(doc):
        saveBook(entry, conn)

Can't do a fetchall() because table and column size are big, and the memory is scarce.

What can be done without resorting to dirty tricks(as getting the rowids in memory, which would probably fit, and then selecting the rows one by one)?.

© Stack Overflow or respective owner

Related posts about python

Related posts about sqlite