Skip to content

Commit

Permalink
Switch column introspection to use sp_columns instead of cursor.columns
Browse files Browse the repository at this point in the history
  • Loading branch information
wgordon17 committed Oct 14, 2020
1 parent a902a95 commit 8b751a9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sql_server/pyodbc/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ 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]):
Expand Down

0 comments on commit 8b751a9

Please sign in to comment.