pyodbc连接到SQL失败

2024-05-04 21:10:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直试图连接到Microsoft SQL Server。我设置了ODBC连接,测试成功。我没有使用Windows身份验证连接到SQL Server,但它始终会出现以下错误:

Cannot be used with Windows authentication

InterfaceError: ('28000', '[28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. (18452) (SQLDriverConnect); [28000] [Microsoft][ODBC SQL Server Driver]Invalid connection string attribute (0); [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. (18452); [28000] [Microsoft][ODBC SQL Server Driver]Invalid connection string attribute (0)')

这是我的代码:

import pyodbc
cnxn = pyodbc.connect(Driver='{SQL Server}',
                      Server='servername.abc.xyz.co.com',
                      username = 'user_xyz', 
                      password = 'abcdfgh')

我正在使用Windows7。请帮我调试这个问题

谢谢


Tags: thesqlauthenticationserveriswindowsdriverwith