pyodbc.OperationalError: ('HYT00', u'[HYT00] [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')

a 夏天 提交于 2020-11-29 23:15:50

问题


Using the SQL Server Management Studio (SSMS) Express, I can find the database and connect without problems.

But when I use pyodbc to connect to the same server using:

    import pyodbc
    Server = r"xxxER\xxxSQLSERV"
    db = "xxxDB"
    user = "xxx"
    password = "xxxx"
    conn = pyodbc.connect('DRIVER={SQL Server};SERVER='+server + ';DATABASE=' + db +';UID=' + user + ';PWD=' + password)

By Using Pyhton in my local i am able to connect but when i am trying in linux server getting below error

pyodbc.OperationalError: ('HYT00', u'[HYT00] [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')

i tried with ODBC Driver 17 for SQL Server too but facing the same issue.Can any one please suggest me on this.


回答1:


Microsoft's SQL Server ODBC drivers for Linux are unable to resolve instance names. You can use the free sqlserverport module to get the corresponding port number and use that to connect.




回答2:


I have this problem and solved my problem in here. Just add version.

conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server + ';DATABASE=' + db +';UID=' + user + ';PWD=' + password)

If not work change version 17 to 13 if not to 11 . List versions of ODBC.




回答3:


Try removing the instance from server and set it as

Server = "xxxER"

or if you have a port number append it as

Server = "xxxER,portNo"



来源:https://stackoverflow.com/questions/54069846/pyodbc-operationalerror-hyt00-uhyt00-unixodbcmicrosoftodbc-driver-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!