summaryrefslogtreecommitdiff
path: root/update_sharing.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2013-06-23 16:33:19 +0200
committerHelmut Grohne <helmut@subdivi.de>2013-06-23 16:33:19 +0200
commitdafdac5f00c1427249f037aaf542881cdbf8f0af (patch)
treece30058c59c21ee4041761f6228f2c94b2ada9bf /update_sharing.py
parent0b45c5f4bfc4a6e3e11843f6040e094a11c17299 (diff)
downloaddebian-dedup-dafdac5f00c1427249f037aaf542881cdbf8f0af.tar.gz
update_sharing: postgres does not support "INSERT OR IGNORE"
Diffstat (limited to 'update_sharing.py')
-rwxr-xr-xupdate_sharing.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/update_sharing.py b/update_sharing.py
index e78e13f..0995114 100755
--- a/update_sharing.py
+++ b/update_sharing.py
@@ -49,8 +49,13 @@ def main():
(hashvalue,)).fetchall()
print("processing hash %s with %d entries" % (hashvalue, len(rows)))
pkgdict = compute_pkgdict(rows)
- conn.execute("INSERT OR IGNORE INTO duplicate (cid) VALUES (?);",
- *[(row[1],) for row in rows])
+ for row in rows:
+ cid = row[1]
+ already = conn.scalar("SELECT cid FROM duplicate WHERE cid = ?;",
+ (cid,))
+ if not already:
+ conn.execute("INSERT INTO duplicate (cid) VALUES (?);",
+ (cid,))
process_pkgdict(conn, pkgdict)
if __name__ == "__main__":