如何在 Linux 上设置 pyodbc 的连接字符串?
我有以下代码,运行良好。
import pyodbc
CONNECTION_STRING="""Driver=ODBC Driver for MS SQL Server 17;
Server=myserver.company.com;
Database=MyDB;
UID=....;
PWD=....;"""
connection = pyodbc.connect(CONNECTION_STRING)
现在我需要更改为我公司的AD/Windows帐户。我尝试过
CONNECTION_STRING="""Driver=ODBC Driver for MS SQL Server 17;
Server=myserver.company.com;
Database=MyDB;
Encrypt=YES;TrustServerCertificate=YES""""
但不起作用?
InterfaceError: ('28000', "[28000] [Microsoft][SQL Server 的 ODBC 驱动程序 17][SQL Server]用户 '' 登录失败。(18456) (SQLDriverConnect)")
并
CONNECTION_STRING="""Driver=ODBC Driver for MS SQL Server 17;
Server=myserver.company.com;
Database=MyDB;
Trusted_Connection=yes"""
收到以下错误
错误:('HY000','[HY000] [Microsoft][适用于 SQL Server 的 ODBC 驱动程序 17]SSPI 提供程序:没有可用的 Kerberos 凭据(默认缓存:KEYRING:持久性:3204410)(851968)(SQLDriverConnect)')
I have the following code which works fine.
import pyodbc
CONNECTION_STRING="""Driver=ODBC Driver for MS SQL Server 17;
Server=myserver.company.com;
Database=MyDB;
UID=....;
PWD=....;"""
connection = pyodbc.connect(CONNECTION_STRING)
Now I need to change to an AD/Windows account of my company. I tried
CONNECTION_STRING="""Driver=ODBC Driver for MS SQL Server 17;
Server=myserver.company.com;
Database=MyDB;
Encrypt=YES;TrustServerCertificate=YES""""
But it doesn't work?
InterfaceError: ('28000', "[28000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user ''. (18456) (SQLDriverConnect)")
And
CONNECTION_STRING="""Driver=ODBC Driver for MS SQL Server 17;
Server=myserver.company.com;
Database=MyDB;
Trusted_Connection=yes"""
got error of
Error: ('HY000', '[HY000] [Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No Kerberos credentials available (default cache: KEYRING:persistent:3204410) (851968) (SQLDriverConnect)')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论