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
Login failures are raised as RuntimeError instead of a mssql_python exception #532
Traceback (most recent call last):
File "mssql_connect.py", line 5, in <module>
connection = connect(
^^^^^^^^^^^^^^
File ".\site-packages\mssql_python\db_connection.py", line 46, in connect
conn = Connection(
^^^^^^^^^^^
File ".\site-packages\mssql_python\connection.py", line 319, in __init__
self._conn = ddbc_bindings.Connection(
^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Login failed for user ''.
I would expect an appropriate mssql_python error to be raised.
The specific use case we have is that we use access tokens to connect to SQL Server. These tokens expire after a certain period of time after which a retry mechanism retries the operation. A mssql_python specific error such as OperationalError would help to better isolate the exceptions that have to be retried.
Hi Martin Studer (@martinstuder), thanks for the details and the clear use case!
You're right, connection-time failures (login, network, driver errors) are currently being raised as RuntimeError instead of the appropriate DB-API 2.0 exceptions. We've root-caused the issue and are working on a fix. We’ll share an update once the fix is in.
Thanks for reporting this issue. The fix is now available in our latest release 1.7.1. Please continue trying out mssql-python, and feel free to keep reporting any issues.
Activity
github-actions commentedon Apr 21, 2026
Hi Martin Studer (@martinstuder), 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!
gargsaumya commentedon May 11, 2026
Hi Martin Studer (@martinstuder), thanks for the details and the clear use case!
You're right, connection-time failures (login, network, driver errors) are currently being raised as RuntimeError instead of the appropriate DB-API 2.0 exceptions. We've root-caused the issue and are working on a fix. We’ll share an update once the fix is in.
FIX: Map connection RuntimeError to correct DB-API 2.0 exception (#532)
Merge branch 'main' into saumya/gh-532
FIX: Map connection RuntimeError to correct DB-API 2.0 exception (#532)
Merge branch 'main' into saumya/gh-532
FIX: GH-Issue (#532) - Login failures are raised as RuntimeError inst…
gargsaumya commentedon May 22, 2026
Thanks for reporting this issue. The fix is now available in our latest release 1.7.1. Please continue trying out mssql-python, and feel free to keep reporting any issues.