--- a/pgtoolkit/pgmanager.py Wed Sep 26 23:32:02 2012 +0200
+++ b/pgtoolkit/pgmanager.py Sat Sep 29 12:08:47 2012 +0200
@@ -139,32 +139,29 @@
def __contains__(self, key):
return key in self._dict
+ def keys(self):
+ return self._dict.keys()
+
class Cursor(psycopg2.extensions.cursor):
def execute(self, query, args=None):
+ # log query before executing
+ self._log_query(query, args)
try:
return super(Cursor, self).execute(query, args)
except DatabaseError:
- # log query and exception
- self._log_query(query, args)
self._log_exception()
raise
- else:
- # log query from self.query
- self._log_query()
def callproc(self, procname, args=None):
+ # log query before executing (not query actually executed but should correspond)
+ self._log_query(self._build_callproc_query(procname, len(args)), args)
try:
return super(Cursor, self).callproc(procname, args)
except DatabaseError:
- # log query and exception
- self._log_query(self._build_callproc_query(procname, len(args)), args)
self._log_exception()
raise
- else:
- # log query from self.query
- self._log_query()
def row_dict(self, row, lstrip=None):
adjustname = lambda a: a
@@ -222,7 +219,7 @@
log_sql.exception('[%s] exception:' % (name,))
def _build_callproc_query(self, procname, num_args):
- return 'SELECT * FROM %s(%s)' %(procname, ', '.join('%s'))
+ return 'SELECT * FROM %s(%s)' % (procname, ', '.join(['%s'] * num_args))
class Connection(psycopg2.extensions.connection):