如何使用 Python 使用系统 DSN 登录 SQL 服务器

How to log into SQL server with System DSN using Python

我正在尝试使用系统 DSN 和 Python 连接到我的 Microsoft SQL Express 数据库。我当前的代码是这样的:

con_string = 'DRIVER={ODBC Driver 17 for SQL Server};SERVER=SQLExpress;DATABASE=pydb;Trusted_Connection=yes;'

如何更改它以使用我的 DSN(使用 Microsoft ODBC Administrator 64 位制作)?

放在这里供参考,访问这个:

https://www.connectionstrings.com/

并找到适合您的 DSN 的连接字符串