无法使用pymssql与Windows身份验证连接 [英] Unable to connect using pymssql with windows authentication

查看:4772
本文介绍了无法使用pymssql与Windows身份验证连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用pymssql连接到MSSQL Server 2012时,出现以下错误。



我的服务器名称在Windows身份验证是SARATH,用户名是Sarath \\ SarathShanker和我没有设置密码。



代码:

  mssql_conn = pymssql.connect(host ='SARATH',user ='Sarath\SarathShanker',password ='',database ='matrix')

错误:


回溯(最近一次呼叫):


中的文件,第1行
pymssql.connect中的文件pymssql.pyx,第556行(pymssql.c:7990)



pymssql.OperationalError:(18452,'登录失败,登录来自不受信任的
域,不能用于Windows authentication.DB-Lib错误消息18452
,严重性14:\\\
General SQL Server错误:检查来自SQL Server \ nDB的消息
-Lib错误消息20002,严重性9:\\\
Adaptive服务器连接失败\\\
DB-Lib
错误消息18452,严重性14:\\\
General SQL服务器错误:检查消息来自
m SQL Server \ nDB-Lib错误消息20002,严重性9:\\\
Adaptive服务器连接
ction失败\\\
')


我应该如何修改我的脚本,以便使用pymssql连接到MSSQL服务器。



pymssql以及。

解决方案

请尝试以下操作:



conn = pymssql.connect(host ='myhost',database ='mydb')



这是使用Python版本3.4和Windows身份验证。


While trying to connect to MSSQL Server 2012 using pymssql, I get the following error.

My server name in Windows Authentication is SARATH,User Name is Sarath\SarathShanker and I did not set a password.

Code:

mssql_conn=pymssql.connect(host='SARATH',user='Sarath\SarathShanker',password='',database='matrix')

Error:

Traceback (most recent call last):
File "", line 1, in
File "pymssql.pyx", line 556, in pymssql.connect (pymssql.c:7990)

pymssql.OperationalError: (18452, 'Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.DB-Lib error message 18452 , severity 14:\nGeneral SQL Server error: Check messages from the SQL Server\nDB -Lib error message 20002, severity 9:\nAdaptive Server connection failed\nDB-Lib error message 18452, severity 14:\nGeneral SQL Server error: Check messages fro m the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server conne ction failed\n')

How should I modify my script in order to connect to MSSQL Server using pymssql.

P.S I have already imported pymssql as well. (Not Shown in Code above)

解决方案

Try this:

conn = pymssql.connect(host='myhost', database='mydb')

This is with Python Version 3.4 and for Windows Authentication.

这篇关于无法使用pymssql与Windows身份验证连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆