3

In _mssql.connect, there is an option to add appname. I'm wondering if pypyodbc.connect has something similar.

Thank you.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
user1327390
  • 131
  • 1
  • 2
  • 7

2 Answers2

7

Yes, as part of the connection string:

DSN=myDatabase;UID=user;PWD=pass;APP=myApp-1.0
tuomur
  • 6,888
  • 34
  • 37
3

Yes, you can use the APP= attribute of the connection string. For example ...

import pypyodbc
connStr = """
DRIVER=SQL Server Native Client 11.0;
SERVER=(local)\SQLEXPRESS;
Trusted_Connection=Yes;
APP=My Python App;
DATABASE=myDb;
"""
db = pypyodbc.connect(connStr)
print("Okay.")
db.close()

... looks like this in SQL Server Profiler

trace.png

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418