[Sqlalchemy-tickets] Issue #3810: Engine creation issue when attempting to use an Azure Data Wareho
Brought to you by:
zzzeek
From: Felipe <iss...@bi...> - 2016-09-30 18:16:42
|
New issue 3810: Engine creation issue when attempting to use an Azure Data Warehouse DB using mssql+pyodbc https://bitbucket.org/zzzeek/sqlalchemy/issues/3810/engine-creation-issue-when-attempting-to Felipe: Whenever trying to create an engine object using the mssql dialect and pyodbc driver, an error will be raised indicating the database_principal_id() does not exist. According to Microsoft Documentation, this is true for their data warehouse, but is still supported in normal Azure Databases. (https://msdn.microsoft.com/en-us/library/ms187319.aspx) With my limited knowledge, I applied a workaround but I am not completely sure the impact it might have in other connections. Edited the **base.py** module to have the following: Line 532: ``` #!python MS_AZURE_VERSION = (12,) ``` Line 1654: ``` #!python def _get_default_schema_name(self, connection): if self.server_version_info < MS_2005_VERSION: return self.schema_name elif self.server_version_info >= MS_AZURE_VERSION: query = sql.text(""" SELECT user_name() """) else: query = sql.text(""" SELECT default_schema_name FROM sys.database_principals WHERE principal_id=database_principal_id() """) default_schema_name = connection.scalar(query) if default_schema_name is not None: return util.text_type(default_schema_name) else: return self.schema_name ``` |