I'm working on simple but large dataset in sqlite using sqlalchemy. I need to iterate over all rows in a table and based on some business logic either update, delete or keep the row.
Because of the size of my data I used the code from http://stackoverflow.com/a/13670855/5462298
to page my query data. The code works fine as long as no rows are
deleted during the processing. Otherwise it will skip over some data. Using yield_per() doesn't seem to work using sqlite for me because I update data during the query which result in a "(sqlite3.ProgrammingError) Cannot operate on a closed database." exception.
What is the proper solution using sqlalchemy for my problem?
Greetings and Thanks in advance,
Tech Q.