diff options
author | Marko Kreen | 2012-05-07 09:01:17 +0000 |
---|---|---|
committer | Marko Kreen | 2012-05-10 18:19:29 +0000 |
commit | 50e239ef59b14e59984b44407d86fc4cde6b8006 (patch) | |
tree | d2755c2aa7bea4db642ca082f9f6e2f0feb15007 | |
parent | 128f094b0852944366856bdc56badb1b27dad40c (diff) |
psycopgwrapper: allow name= argument to .cursor()
-rw-r--r-- | python/skytools/psycopgwrapper.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/python/skytools/psycopgwrapper.py b/python/skytools/psycopgwrapper.py index 8c6d90b6..7cca9e23 100644 --- a/python/skytools/psycopgwrapper.py +++ b/python/skytools/psycopgwrapper.py @@ -107,8 +107,14 @@ class _CompatCursor(psycopg2.extras.DictCursor): class _CompatConnection(psycopg2.extensions.connection): """Connection object that uses _CompatCursor.""" my_name = '?' - def cursor(self): - return psycopg2.extensions.connection.cursor(self, cursor_factory = _CompatCursor) + def cursor(self, name = None): + if name: + return psycopg2.extensions.connection.cursor(self, + cursor_factory = _CompatCursor, + name = name) + else: + return psycopg2.extensions.connection.cursor(self, + cursor_factory = _CompatCursor) def connect_database(connstr, keepalive = True, tcp_keepidle = 4 * 60, # 7200 |