mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-13 04:26:33 +03:00
Use set_session instead of set_isolation_level where available
Avoid spurious queries as reported in psycopg2 ticket #125.
This commit is contained in:
parent
f9bcbc213e
commit
fb24777200
|
@ -52,6 +52,11 @@ class DB(TM, dbi_db.DB):
|
|||
# connection, so we avoid to (re)initialize it risking errors.
|
||||
conn = pool.getconn(self.dsn)
|
||||
if init:
|
||||
# use set_session where available as in these versions
|
||||
# set_isolation_level generates an extra query.
|
||||
if psycopg2.__version__ >= '2.4.2':
|
||||
conn.set_session(isolation_level=int(self.tilevel))
|
||||
else:
|
||||
conn.set_isolation_level(int(self.tilevel))
|
||||
conn.set_client_encoding(self.encoding)
|
||||
for tc in self.typecasts:
|
||||
|
|
Loading…
Reference in New Issue
Block a user