Skip to content

Cursor.description returns varchar column type for date column #425

@sdebruyn

Description

@sdebruyn

Describe the bug

I have a SQL statement which should have a single date column. The .description property of the cursor returns a str though. Same code with pyODBC does give a date.

SQL:

"\n\n    with __dbt_sbq_tmp as (\n        \n\nselect\n  cast('2019-01-01' as date) as wrong_data_type_column_name\n    )\n    select * from __dbt_sbq_tmp\n    where 0 = 1\n\n"

Python:

sql = ... (see above)
handle = mssql_python.connect(conn_str, autocommit=True)
cursor = handle.cursor()
cursor.execute(sql)

Content of cursor.description:

('wrong_data_type_column_name', <class 'str'>, None, 10, 10, 0, True)

What pyODBC gives as cursor.description:

(('wrong_data_type_column_name', <class 'datetime.date'>, None, 10, 10, 0, True),)

Further technical details

Python version: 3.13
SQL Server version: Fabric Data Warehouse
Operating system: macOS

I suspect this might be the same as #352 but not 100% sure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions