summaryrefslogtreecommitdiff
path: root/update_sharing.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2013-07-20 14:09:30 +0200
committerHelmut Grohne <helmut@subdivi.de>2013-07-20 14:09:30 +0200
commit302a3b17c5905ad9e1bc9c7c32857729c1dd41aa (patch)
tree883a02deb3b41e4dc5b28b8089f4fddc9ffe44e2 /update_sharing.py
parented3e611cfc54b8c916e919701070bfd5c6770610 (diff)
downloaddebian-dedup-302a3b17c5905ad9e1bc9c7c32857729c1dd41aa.tar.gz
use sqlalchemy.text
Without using this wrapper the sql statements are not munged by sqlalchemy. Specifically paramstyle is not translated. For sqlite3 this did not matter, because it allows the changed paramstyle, but for postgres it fails without sqlalchemy.text wrappers.
Diffstat (limited to 'update_sharing.py')
-rwxr-xr-xupdate_sharing.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/update_sharing.py b/update_sharing.py
index 664b627..f8300f6 100755
--- a/update_sharing.py
+++ b/update_sharing.py
@@ -7,11 +7,11 @@ from dedup.utils import fetchiter, enable_sqlite_foreign_keys
def add_values(conn, insert_key, files, size):
params = dict(files=files, size=size, pid1=insert_key[0],
pid2=insert_key[1], func1=insert_key[2], func2=insert_key[3])
- rows = conn.execute("UPDATE sharing SET files = files + :files, size = size + :size WHERE pid1 = :pid1 AND pid2 = :pid2 AND func1 = :func1 AND func2 = :func2;",
+ rows = conn.execute(sqlalchemy.text("UPDATE sharing SET files = files + :files, size = size + :size WHERE pid1 = :pid1 AND pid2 = :pid2 AND func1 = :func1 AND func2 = :func2;"),
**params)
if rows.rowcount > 0:
return
- conn.execute("INSERT INTO sharing (pid1, pid2, func1, func2, files, size) VALUES (:pid1, :pid2, :func1, :func2, :files, :size);",
+ conn.execute(sqlalchemy.text("INSERT INTO sharing (pid1, pid2, func1, func2, files, size) VALUES (:pid1, :pid2, :func1, :func2, :files, :size);"),
**params)
def compute_pkgdict(rows):
@@ -47,7 +47,7 @@ def main():
conn.execute("DELETE FROM duplicate;")
readcur = conn.execute("SELECT hash FROM hash GROUP BY hash HAVING count(*) > 1;")
for hashvalue, in fetchiter(readcur):
- rows = conn.execute("SELECT content.pid, content.id, content.filename, content.size, hash.function FROM hash JOIN content ON hash.cid = content.id WHERE hash = :hashvalue;",
+ rows = conn.execute(sqlalchemy.text("SELECT content.pid, content.id, content.filename, content.size, hash.function FROM hash JOIN content ON hash.cid = content.id WHERE hash = :hashvalue;"),
hashvalue=hashvalue).fetchall()
print("processing hash %s with %d entries" % (hashvalue, len(rows)))
pkgdict = compute_pkgdict(rows)
@@ -56,7 +56,7 @@ def main():
already = conn.scalar("SELECT cid FROM duplicate WHERE cid = :cid;",
cid=cid)
if not already:
- conn.execute("INSERT INTO duplicate (cid) VALUES (:cid);",
+ conn.execute(sqlalchemy.text("INSERT INTO duplicate (cid) VALUES (:cid);"),
cid=cid)
process_pkgdict(conn, pkgdict)