diff options
author | Helmut Grohne <helmut@subdivi.de> | 2013-06-23 13:30:04 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2013-06-23 13:33:05 +0200 |
commit | 0b45c5f4bfc4a6e3e11843f6040e094a11c17299 (patch) | |
tree | 0c73981f7960955899cdbbf8be14586f00e9c3ba /dedup/utils.py | |
parent | 75cc8a9998d32e714a05760e968e38b71c2ac157 (diff) | |
download | debian-dedup-0b45c5f4bfc4a6e3e11843f6040e094a11c17299.tar.gz |
dedup.utils: add enbale_sqlite_foreign_keys helper
Makes usage of sqlalchemy easier, cause I can invoke it once and it
works for all connections.
Diffstat (limited to 'dedup/utils.py')
-rw-r--r-- | dedup/utils.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/dedup/utils.py b/dedup/utils.py index 2fae9fd..e4d1c10 100644 --- a/dedup/utils.py +++ b/dedup/utils.py @@ -1,3 +1,5 @@ +import sqlalchemy.event + def fetchiter(cursor): rows = cursor.fetchmany() while rows: @@ -5,3 +7,8 @@ def fetchiter(cursor): 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;") + |