summaryrefslogtreecommitdiff
path: root/dedup/utils.py
blob: 6864ad3a0f5b26069c2ee7419d71021dea0e4a1c (plain)
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;")