diff options
author | Marko Kreen | 2011-12-08 16:15:28 +0000 |
---|---|---|
committer | Marko Kreen | 2011-12-08 16:33:16 +0000 |
commit | b1e3350a364282b22c69236af6a2b5654cae8b28 (patch) | |
tree | 20691aa41e602b8cc83a1a0acc7839da4439a47c /python/skytools/psycopgwrapper.py | |
parent | 8227d443103bf209d7a5d60b8dd9cabe8452ac55 (diff) |
skytools: seems psycopg2 isolation constants do change
Psycopg 2.4.2 moved them around.
Stop hard-coding them, instead import from psycopg2.externsions
Also have a symbol for repeatable read.
Diffstat (limited to 'python/skytools/psycopgwrapper.py')
-rw-r--r-- | python/skytools/psycopgwrapper.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/python/skytools/psycopgwrapper.py b/python/skytools/psycopgwrapper.py index 923b6f39..8c6d90b6 100644 --- a/python/skytools/psycopgwrapper.py +++ b/python/skytools/psycopgwrapper.py @@ -54,21 +54,25 @@ Plain .fetchall() / .fetchone() give exact same result. """ -# no exports -__all__ = ['connect_database', 'DBError'] +__all__ = ['connect_database', 'DBError', 'I_AUTOCOMMIT', 'I_READ_COMMITTED', + 'I_REPEATABLE_READ', 'I_SERIALIZABLE'] -##from psycopg2.psycopg1 import connect as _pgconnect -# psycopg2.psycopg1.cursor is too backwards compatible, -# to the point of avoiding optimized access. -# only backwards compat thing we need is dict* methods - -import sys, socket -import psycopg2.extensions, psycopg2.extras -from psycopg2 import Error as DBError +import sys +import socket +import psycopg2.extensions +import psycopg2.extras import skytools +from psycopg2 import Error as DBError from skytools.sockutil import set_tcp_keepalive + +I_AUTOCOMMIT = psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT +I_READ_COMMITTED = psycopg2.extensions.ISOLATION_LEVEL_READ_COMMITTED +I_REPEATABLE_READ = psycopg2.extensions.ISOLATION_LEVEL_REPEATABLE_READ +I_SERIALIZABLE = psycopg2.extensions.ISOLATION_LEVEL_SERIALIZABLE + + class _CompatRow(psycopg2.extras.DictRow): """Make DictRow more dict-like.""" __slots__ = ('_index',) |