summaryrefslogtreecommitdiff
path: root/dedup/utils.py
blob: e4d1c10e79bb29d7818297b26fe93689fb6fbc8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import sqlalchemy.event

def fetchiter(cursor):
    rows = cursor.fetchmany()
    while rows:
        for row in rows:
            yield row
        rows = cursor.fetchmany()

def enable_sqlite_foreign_keys(engine):
    @sqlalchemy.event.listens_for(engine, "connect")
    def pragma_foreign_keys(connection, _):
        connection.execute("PRAGMA foreign_keys=ON;")