Skip to content

Allow a caller-supplied Application Name (APP) instead of hardcoding "MSSQL-Python" #649

Closed

Description

@sdebruyn

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.py removes APP from the user-supplied connection string (it is in _RESERVED_PARAMETERS).
  • connection.py raises ValueError if APP is passed via connect() kwargs (reserved parameter).
  • connection.py then 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_python cannot identify themselves in sys.dm_exec_sessions.program_name or in query history; everything is attributed to MSSQL-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 an APP= 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="..." (or app="...") keyword on connect() / 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.

Activity

  1. github-actions commented on Jun 27, 2026

    @github-actions

    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!

  2. jahnvi480 commented on Jun 29, 2026

    @jahnvi480
    Contributor

    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.

  3. added
    enhancementNew feature or request
    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 29, 2026
  4. sumitmsft commented on Jul 8, 2026

    @sumitmsft
    Contributor

    Closing this issue and tracking it through #484

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.duplicateThis issue or pull request already existsenhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions