Skip to content

DOMAIN\user SQL Server login works with pyodbc/FreeTDS but fails with mssql_python #625

Description

@Tage-Politi

I am using mssql_python against an on-prem SQL Server using a domain-style username DOMAIN\username but with a password.

The same server, database, username and password work when using pyodbc with the FreeTDS ODBC driver, but fail with mssql_python. The error message is

mssql_python.exceptions.OperationalError: Driver Error: Invalid authorization specification; DDBC Error: [Microsoft][SQL Server]Login failed for user 'DOMAIN\username'.

To reproduce

This code below works:

import pyodbc
s=r"DRIVER=FreeTDS;SERVER=servername;PORT=1433;DATABASE=DM_Database;UID=DOMAIN\username;PWD=J...;TDS_Version=7.4;Encrypt=yes"
conn = pyodbc.connect(_s)

This code below fails with the message reported above:

import mysql_python
s = r"SERVER=servername,1433;Database=DM_Database;UID=DOMAIN\username;PWD=J...;Encrypt=yes;
conn = mssql_python.connect(s)

Further technical details

Python version: 3.10.12
mssql_python: 1.8.0
SQL Server version: SQL Server 2022 (Must be verified, but this is what my documentation says)
Operating system: Ubuntu 22.04.5 LTS

Activity

  1. github-actions commented on Jun 4, 2026

    @github-actions

    Hi Tage-Politi, 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!

  2. Tage-Politi commented on Jun 4, 2026

    @Tage-Politi
    Author

    Database confirmeed to be:

    Microsoft SQL Server 2022 (RTM-CU24-GDR) (KB5089900) - 16.0.4252.3 (X64) 
    	Apr 26 2026 07:08:29 
    	Copyright (C) 2022 Microsoft Corporation
    	Developer Edition (64-bit) on Windows Server 2022 Datacenter 10.0 <X64> (Build 20348: ) (Hypervisor)
    
  3. added
    triage doneIssues that are triaged by dev team and are in investigation.
    area: connectivity-authConnection lifecycle, Entra/SP/NTLM auth, tokens, TLS, conn-string parsing, Fabric endpoints.
    and removed
    triage neededFor new issues, not triaged yet.
    on Jun 5, 2026
  4. sumitmsft commented on Jul 6, 2026

    @sumitmsft
    Contributor

    Hi Tage-Politi Thanks for the report. Since you’re running on Ubuntu 22.04, we want to clarify the authentication mode here.

    Since your working comparison uses pyodbc with FreeTDS, this may reflect a driver-specific behavior difference rather than a bug in mssql_python.

    Can you confirm whether DOMAIN\username is a SQL login whose literal name includes a backslash?

    If it’s the latter, we can investigate further as a compatibility issue.

  5. Tage-Politi commented on Jul 7, 2026

    @Tage-Politi
    Author

    For mundane reasons and this particular use-case, the username unfortunately is indeed the name of a domain, a \, and then a "classic" username.
    The pyodbc-driver seems to pass the username through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area: connectivity-authConnection lifecycle, Entra/SP/NTLM auth, tokens, TLS, conn-string parsing, Fabric endpoints.inADOquestionFurther information is requestedtriage doneIssues that are triaged by dev team and are in investigation.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions