Skip to content

Login failures are raised as RuntimeError instead of a mssql_python exception #532

@martinstuder

Description

@martinstuder

Login failures raised during connect are raised as RuntimeError instead of a mssql_python exception (see https://github.com/microsoft/mssql-python/wiki/Exception):

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage neededFor new issues, not triaged yet.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions