1 2 3 4 5 6 7 8 9 10 11 12 13 14
import sqlalchemy.event def fetchiter(cursor): rows = cursor.fetchmany(1024) while rows: for row in rows: yield row rows = cursor.fetchmany(1024) def enable_sqlite_foreign_keys(engine): @sqlalchemy.event.listens_for(engine, "connect") def pragma_foreign_keys(connection, _): connection.execute("PRAGMA foreign_keys=ON;")