From e6cc6c64ab46f5d724c8121cdc7deeb48a3bcbfc Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sat, 8 Mar 2014 17:38:26 +0100 Subject: add sqlalchemy.text wrapper Without the wrapper sqlalchemy chokes on the query and tries to index some dictionary on postgres. --- update_sharing.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/update_sharing.py b/update_sharing.py index e41bceb..b6b0fdb 100755 --- a/update_sharing.py +++ b/update_sharing.py @@ -67,9 +67,9 @@ def main(db): conn.execute(sqlalchemy.text("INSERT INTO duplicate (cid) VALUES (:cid);"), cid=cid) process_pkgdict(conn, pkgdict) - conn.execute("INSERT INTO issue (cid, issue) SELECT content.id, 'file named something.gz is not a valid gzip file' FROM content WHERE content.filename LIKE '%.gz' AND NOT EXISTS (SELECT 1 FROM hash JOIN function ON hash.fid = function.id WHERE hash.cid = content.id AND function.name = 'gzip_sha512');") - conn.execute("INSERT INTO issue (cid, issue) SELECT content.id, 'png image not named something.png' FROM content JOIN hash ON content.id = hash.cid JOIN function ON hash.fid = function.id WHERE function.name = 'png_sha512' AND lower(filename) NOT LIKE '%.png';") - conn.execute("INSERT INTO issue (cid, issue) SELECT content.id, 'gif image not named something.gif' FROM content JOIN hash ON content.id = hash.cid JOIN function ON hash.fid = function.id WHERE function.name = 'gif_sha512' AND lower(filename) NOT LIKE '%.gif';") + conn.execute(sqlalchemy.text("INSERT INTO issue (cid, issue) SELECT content.id, 'file named something.gz is not a valid gzip file' FROM content WHERE content.filename LIKE '%.gz' AND NOT EXISTS (SELECT 1 FROM hash JOIN function ON hash.fid = function.id WHERE hash.cid = content.id AND function.name = 'gzip_sha512');")) + conn.execute(sqlalchemy.text("INSERT INTO issue (cid, issue) SELECT content.id, 'png image not named something.png' FROM content JOIN hash ON content.id = hash.cid JOIN function ON hash.fid = function.id WHERE function.name = 'png_sha512' AND lower(filename) NOT LIKE '%.png';")) + conn.execute(sqlalchemy.text("INSERT INTO issue (cid, issue) SELECT content.id, 'gif image not named something.gif' FROM content JOIN hash ON content.id = hash.cid JOIN function ON hash.fid = function.id WHERE function.name = 'gif_sha512' AND lower(filename) NOT LIKE '%.gif';")) if __name__ == "__main__": parser = optparse.OptionParser() -- cgit v1.2.3