You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[MSSQL-Django] Expose SQL Server type constants (SQL_SS_TIME2, SQL_SS_XML, SQL_SS_VARIANT) at module level #763
mssql_python does not expose the SQL Server-specific ODBC type constants at the package level, even though they already exist in the internal ConstantsDDBC enum. pyodbc exposes them as module-level attributes:
SQL_SS_TIME2 = -154
SQL_SS_XML = -152
SQL_SS_VARIANT = -150
In mssql_python these are reachable only via mssql_python.constants.ConstantsDDBC.SQL_SS_TIME2.value. mssql_python.SQL_SS_TIME2 raises AttributeError.
Why it matters
Code written against pyodbc reads these constants off the driver module directly. Django's SQL Server backend is a concrete example: its introspection maps the time column type using Database.SQL_SS_TIME2, where Database is the imported driver module. Against pyodbc that resolves. Against mssql_python it raises AttributeError, so the consumer has to add a fallback:
That hard-codes an ODBC type code in every consumer, which is exactly what the driver should own. Exposing the constant at module level removes the fallback and keeps mssql_python drop-in compatible with pyodbc for this surface.
Repro
importmssql_pythonimportpyodbcprint(pyodbc.SQL_SS_TIME2) # -154print(mssql_python.SQL_SS_TIME2) # AttributeError: module 'mssql_python' has no attribute 'SQL_SS_TIME2'
Proposed fix
Promote the SQL Server type constants that pyodbc exposes (SQL_SS_TIME2, SQL_SS_XML, SQL_SS_VARIANT) to module-level public API, following the existing pattern already used for SQL_VARCHAR, SQL_GUID, and the rest. The values already live in ConstantsDDBC, so this is a re-export plus __all__ and type-stub updates, with no new values.
Open question
ConstantsDDBC also defines SQL_SS_UDT (-151) and SQL_DATETIMEOFFSET (-155). pyodbc does not expose either at module level, so this proposal leaves them internal to keep the public surface aligned with pyodbc. They can be added if there is a reason to.
changed the title [-]Expose SQL Server type constants (SQL_SS_TIME2, SQL_SS_XML, SQL_SS_VARIANT) at module level for pyodbc parity[/-][+][MSSQL-Django] Expose SQL Server type constants (SQL_SS_TIME2, SQL_SS_XML, SQL_SS_VARIANT) at module level[/+]on Sep 9, 2026
Activity
github-actions commentedon Sep 9, 2026
Hi Gaurav Sharma (@bewithgaurav), thank you for opening this issue!
Our team will review it shortly. We aim to triage all new issues within 24-48 hours and get back to you.
If you have additional information to share, please feel free to update the issue.
Thank you for your patience!
[-]Expose SQL Server type constants (SQL_SS_TIME2, SQL_SS_XML, SQL_SS_VARIANT) at module level for pyodbc parity[/-][+][MSSQL-Django] Expose SQL Server type constants (SQL_SS_TIME2, SQL_SS_XML, SQL_SS_VARIANT) at module level[/+]FEAT: Expose SQL Server type constants at module level (#764)