Mercurial > hg > ZDBInterface
changeset 18:60fea3a6c695
better fix for psycopg 2.4. better quoting of sql arguments.
author | casties |
---|---|
date | Thu, 23 Feb 2012 21:17:14 +0100 |
parents | 48ed91b29784 |
children | 132ae1c0255a |
files | DBInterface.py RestDbInterface.py |
diffstat | 2 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/DBInterface.py Thu Feb 23 08:33:48 2012 +0100 +++ b/DBInterface.py Thu Feb 23 21:17:14 2012 +0100 @@ -171,11 +171,15 @@ cur.execute(query, args) # description of returned fields fields = cur.description - logging.debug("fields: %s"%repr(fields)) + #logging.debug("fields: %s"%repr(fields)) if len(fields) > 0: # re-pack Column object in tuple - fields = (f[0:] for f in fields) - logging.debug("re-packed fields: %s"%repr(fields)) + fs = [] + for f in fields: + fs.append(f[0:]) + + fields = fs + #logging.debug("re-packed fields: %s"%repr(fields)) if hasResult: # get all data in an array
--- a/RestDbInterface.py Thu Feb 23 08:33:48 2012 +0100 +++ b/RestDbInterface.py Thu Feb 23 21:17:14 2012 +0100 @@ -181,9 +181,9 @@ """return table data""" logging.debug("gettable") if sortBy: - data = self.executeSQL('select * from "%s"."%s" order by %s'%(schema,table,sortBy)) + data = self.executeSQL('select * from "%s"."%s" order by %%s'%(sqlName(schema),sqlName(table)),(sortBy,)) else: - data = self.executeSQL('select * from "%s"."%s"'%(schema,table)) + data = self.executeSQL('select * from "%s"."%s"'%(sqlName(schema),sqlName(table))) return data def hasTable(self,schema='public',table=None,username='guest'):