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 /update_sharing.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 'update_sharing.py')
-rwxr-xr-x | update_sharing.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/update_sharing.py b/update_sharing.py index bbd19e5..e78e13f 100755 --- a/update_sharing.py +++ b/update_sharing.py @@ -2,7 +2,7 @@ import sqlalchemy -from dedup.utils import fetchiter +from dedup.utils import fetchiter, enable_sqlite_foreign_keys def add_values(conn, insert_key, files, size): rows = conn.execute("UPDATE sharing SET files = files + ?, size = size + ? WHERE package1 = ? AND package2 = ? AND func1 = ? AND func2 = ?;", @@ -39,8 +39,8 @@ def process_pkgdict(conn, pkgdict): def main(): db = sqlalchemy.create_engine("sqlite:///test.sqlite3") + enable_sqlite_foreign_keys(db) with db.begin() as conn: - conn.execute("PRAGMA foreign_keys = ON;") conn.execute("DELETE FROM sharing;") conn.execute("DELETE FROM duplicate;") readcur = conn.execute("SELECT hash FROM hash GROUP BY hash HAVING count(*) > 1;") |