From bc1c58774e747354ca14497d02cd3d98a5197157 Mon Sep 17 00:00:00 2001 From: Will Gordon Date: Tue, 13 Oct 2020 21:19:41 -0400 Subject: [PATCH] Switch column introspection to use sp_columns instead of cursor.columns --- sql_server/pyodbc/introspection.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sql_server/pyodbc/introspection.py b/sql_server/pyodbc/introspection.py index 82f4c910..3f334e30 100644 --- a/sql_server/pyodbc/introspection.py +++ b/sql_server/pyodbc/introspection.py @@ -93,8 +93,12 @@ def get_table_description(self, cursor, table_name, identity_check=True): of SQL_BIGAUTOFIELD, which maps to the 'BigAutoField' value in the DATA_TYPES_REVERSE dict. """ - # map pyodbc's cursor.columns to db-api cursor description - columns = [[c[3], c[4], None, c[6], c[6], c[8], c[10], c[12]] for c in cursor.columns(table=table_name)] + # map T-SQL's `sp_columns` stored procedure to db-api cursor description + # https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-columns-transact-sql + columns = [ + [c[3], c[4], None, c[6], c[6], c[8], c[10], c[12]] + for c in cursor.execute('exec sp_columns %s', [table_name]).fetchall() + ] items = [] for column in columns: if identity_check and self._is_auto_field(cursor, table_name, column[0]):