projects
/
skytools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7c61751
)
psycopgwrapper: Fill .server_version on older psycopg
author
Marko Kreen
<markokr@gmail.com>
Wed, 28 Oct 2009 14:00:51 +0000
(16:00 +0200)
committer
Marko Kreen
<markokr@gmail.com>
Tue, 3 Nov 2009 12:43:44 +0000
(14:43 +0200)
This make the parameter always available.
python/skytools/psycopgwrapper.py
patch
|
blob
|
blame
|
history
diff --git
a/python/skytools/psycopgwrapper.py
b/python/skytools/psycopgwrapper.py
index 1c91ea97c45500149db18d7e4f106d7a1b82dd0d..0cd053a1ce8dc331b8c154b52c806b1fe7511e61 100644
(file)
--- a/
python/skytools/psycopgwrapper.py
+++ b/
python/skytools/psycopgwrapper.py
@@
-113,5
+113,15
@@
def connect_database(connstr):
connstr += " connect_timeout=15"
# create connection
- return _CompatConnection(connstr)
+ db = _CompatConnection(connstr)
+
+ # fill .server_version on older psycopg
+ if not hasattr(db, 'server_version'):
+ iso = db.isolation_level
+ db.set_isolation_level(0)
+ curs = db.cursor()
+ curs.execute('show server_version_num')
+ db.server_version = curs.fetchone()[0]
+ db.set_isolation_level(iso)
+ return db