From c02e95ed33504f2738261e4e80c28382f94d8d51 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 21 Jul 2014 11:58:44 -0400 Subject: - Fixed bug introduced in 0.9.5 by new pg8000 isolation level feature where engine-level isolation level parameter would raise an error on connect. fixes #3134 --- lib/sqlalchemy/dialects/postgresql/pg8000.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py index 512f3e1b0..589567d9e 100644 --- a/lib/sqlalchemy/dialects/postgresql/pg8000.py +++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py @@ -150,10 +150,14 @@ class PGDialect_pg8000(PGDialect): def set_isolation_level(self, connection, level): level = level.replace('_', ' ') + # adjust for ConnectionFairy possibly being present + if hasattr(connection, 'connection'): + connection = connection.connection + if level == 'AUTOCOMMIT': - connection.connection.autocommit = True + connection.autocommit = True elif level in self._isolation_lookup: - connection.connection.autocommit = False + connection.autocommit = False cursor = connection.cursor() cursor.execute( "SET SESSION CHARACTERISTICS AS TRANSACTION " -- cgit v1.2.1