Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch column introspection to use sp_columns instead of cursor.columns #199

Open
wants to merge 1 commit into
base: azure-2.1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions sql_server/pyodbc/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down