microsoft / microsoft/mssql-python

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

Open
#625 4 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

area: connectivity-auth inADO question triage done
Dominant language
Python
Stars
472
Forks
60
Avg merge
2d 11h
Merged PRs (30d)
36

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.