diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2018-06-25 22:42:40 -0400 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci.zzzcomputing.com> | 2018-06-25 22:42:40 -0400 |
| commit | 441bf421cf88966393edcf5ace5a2836096022e9 (patch) | |
| tree | cde2d49e2461744f53d36e14635245a3c703e5ef /lib/sqlalchemy | |
| parent | 677818707471db670d5c3a83b10ebbc65f871881 (diff) | |
| parent | e2913f65c4e5720394105584c69e7b9e8c2d373c (diff) | |
| download | sqlalchemy-441bf421cf88966393edcf5ace5a2836096022e9.tar.gz | |
Merge "Fix UnboundLocalError in mssql during isolation level grab"
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/dialects/mssql/base.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 2975a6c69..bc3905535 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -1897,6 +1897,8 @@ class MSDialect(default.DefaultDialect): raise NotImplementedError( "Can't fetch isolation level prior to SQL Server 2005") + last_error = None + views = ("sys.dm_exec_sessions", "sys.dm_pdw_nodes_exec_sessions") for view in views: cursor = connection.cursor() @@ -1914,19 +1916,22 @@ class MSDialect(default.DefaultDialect): """ % view) val = cursor.fetchone()[0] except self.dbapi.Error as err: + # Python3 scoping rules + last_error = err continue else: return val.upper() finally: cursor.close() + else: + util.warn( + "Could not fetch transaction isolation level, " + "tried views: %s; final error was: %s" % (views, last_error)) - util.warn( - "Could not fetch transaction isolation level, " - "tried views: %s; final error was: %s" % (views, err)) - raise NotImplementedError( - "Can't fetch isolation level on this particular " - "SQL Server version" - ) + raise NotImplementedError( + "Can't fetch isolation level on this particular " + "SQL Server version" + ) def initialize(self, connection): super(MSDialect, self).initialize(connection) |
