[英][Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
I am unable to make a connection to the SQL server from Unix using python. 我无法使用python从Unix建立到SQL Server的连接。
I will not be able to replace the driver from ODBC Driver 17 for SQL Server to ODBC Driver 13 for SQL Server as explained in Pyodbc: Login Timeout Error due to other dependencies. 我将无法将驱动程序从SQL Server的ODBC驱动程序17替换为SQL Server的ODBC驱动程序13,如Pyodbc:登录超时错误中所述,由于其他依赖性。
Can somebody please suggest an alternative? 有人可以建议替代方法吗?
CODE: 码:
import sqlalchemy as sa
from urllib import parse as db_parse
from sqlalchemy import event
params = db_parse.quote_plus(r"DRIVER={ODBC Driver 17 for SQL Server};SERVER='server,port';DATABASE=DB_NAME;username=USER_ID;password=PWD;Trusted_Connection=yes")
engine = sa.create_engine('mssql+pyodbc:///?odbc_connect={}'.format(params))
connection = engine.connect()
ERROR: 错误:
sqlalchemy.exc.OperationalError: (pyodbc.OperationalError) ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)') (Background on this error at: http://sqlalche.me/e/e3q8)
My connection string looks different: 我的连接字符串看起来不同:
"DRIVER={ODBC Driver 17 for SQL Server};SERVER=myserver;DATABASE=mydb;UID=myuser;PWD=mypassword"
leeds to 利兹
import pyodbc
connection = pyodbc.connect("DRIVER={ODBC Driver 17 for SQL Server};SERVER=myserver;DATABASE=mydb;UID=myuser;PWD=mypassword", autocommit=True)
Instead of UID you are using username, etc. All words starting with 'my' have to be replaced with the actual db, user and password. 您使用的是用户名等,而不是UID。必须将所有以“ my”开头的单词替换为实际的数据库,用户和密码。 You should also remove the
Trusted_Connection=True;
您还应该删除
Trusted_Connection=True;
part as Panagiotis Kanavos pointed out in the comment. 正如Panagiotis Kanavos在评论中指出的那样。 This says you are using your windows-user to authenticate (which is obviously not available on linux).
这表示您正在使用Windows用户进行身份验证(Linux上显然不可用)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.