Repository navigation
Allow a caller-supplied Application Name (APP) instead of hardcoding "MSSQL-Python" #649
Copy link
Copy link
Closed
Labels
area: connectivity-authConnection lifecycle, Entra/SP/NTLM auth, tokens, TLS, conn-string parsing, Fabric endpoints.Connection lifecycle, Entra/SP/NTLM auth, tokens, TLS, conn-string parsing, Fabric endpoints.duplicateThis issue or pull request already existsThis issue or pull request already existsenhancementNew feature or requestNew feature or request
Description
Summary
mssql_python does not let an application set its own Application Name on a connection. The driver reserves the APP connection-string parameter and always overrides it with the literal "MSSQL-Python", so every connection reports program_name = MSSQL-Python in sys.dm_exec_sessions and in the Fabric / SQL Server query history.
Details (as of mssql-python 1.9.0)
connection_string_parser.pyremovesAPPfrom the user-supplied connection string (it is in_RESERVED_PARAMETERS).connection.pyraisesValueErrorifAPPis passed viaconnect()kwargs (reserved parameter).connection.pythen unconditionally sets, after processing kwargs:# Step 4: Add Driver and APP (always controlled by the driver). normalized_params["Driver"] = "ODBC Driver 18 for SQL Server" normalized_params["APP"] = "MSSQL-Python"
So there is currently no supported way (connection string or kwarg) for a caller to set the application name.
Why this matters
- Tools and services built on
mssql_pythoncannot identify themselves insys.dm_exec_sessions.program_nameor in query history; everything is attributed toMSSQL-Python, which makes per-application monitoring, auditing and troubleshooting much harder. - Microsoft Fabric (and SQL Server) support workload classification / routing by Application Name. With the name pinned to
MSSQL-Python, callers cannot route their workloads to a custom classifier. - The ODBC Driver itself, and
pyodbc, both honour anAPP=value supplied by the caller.
Request
Let callers set the application name, while keeping MSSQL-Python as the default when none is supplied. For example:
- honour an
APP=...value present in the connection string, or - accept an
application_name="..."(orapp="...") keyword onconnect()/Connection(...),
falling back to "MSSQL-Python" only when the caller did not provide one.
Repro
import mssql_python
conn = mssql_python.connect("Server=...;Database=...;Encrypt=yes;APP=MyApp")
cur = conn.cursor()
cur.execute("SELECT program_name FROM sys.dm_exec_sessions WHERE session_id = @@SPID")
print(cur.fetchone()) # -> ('MSSQL-Python',) (expected: 'MyApp')Thanks for the driver, otherwise it has been a pleasure to build on.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: connectivity-authConnection lifecycle, Entra/SP/NTLM auth, tokens, TLS, conn-string parsing, Fabric endpoints.Connection lifecycle, Entra/SP/NTLM auth, tokens, TLS, conn-string parsing, Fabric endpoints.duplicateThis issue or pull request already existsThis issue or pull request already existsenhancementNew feature or requestNew feature or request
Activity
github-actions commentedon Jun 27, 2026
Hi Sam Debruyn (@sdebruyn), 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!
jahnvi480 commentedon Jun 29, 2026
Hello Sam Debruyn (@sdebruyn) , Thanks for raising this issue, we already have one open issue for App name. #484 . We are looking into it and have it in our priority list. We will update you once we make any progress.
sumitmsft commentedon Jul 8, 2026
Closing this issue and tracking it through #484