[英]Pyodbc login time out error with (Azure) SQL Server
I am getting a strange error with Python condo environments and PyODBC.我在 Python 公寓环境和 PyODBC 中遇到一个奇怪的错误。 I have multiple Conda environments, I am able to connect from one of the environment (from a Linux machine) to SQL Server hosted on Azure but not from the other one.我有多个 Conda 环境,我能够从其中一个环境(从 Linux 机器)连接到 SQL 服务器托管在 Azure 上,但不能从另一个环境连接。 Both Python environments have version 3.7.7 of Python and version 4.0.0 of Pyodbc. Python 环境都有 Python 的 3.7.7 版本和 Pyodbc 的 4.0.0 版本。 Code is exactly the same and connection string uses SQL Server 17 driver.代码完全相同,连接字符串使用 SQL Server 17 驱动程序。
conn_str='DRIVER={ODBC Driver 17 for SQL Server};SERVER=' +server+';Authentication=ActiveDirectoryPassword;DATABASE='+database+';UID='+self.user_name+';PWD='+self.password
Error is:错误是:
pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)') pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][SQL 服务器的 ODBC 驱动程序 17] 登录超时已过期 (0) (SQLDriverConnect)')
As you can see above, the issue might be DNS-related.如您所见,问题可能与 DNS 相关。 In the connection string, try using an IP address instead of the hostname, or check your DNS setup.在连接字符串中,尝试使用 IP 地址代替主机名,或检查您的 DNS 设置。
Try downgrade to ODBC driver 13 and have a try.尝试降级到 ODBC 驱动程序 13 并试一试。 For that version 17 needs to be uninstalled.对于该版本,需要卸载 17。
Try using connect from SQL Authentication instead of Active Directory Password.尝试使用来自 SQL 身份验证的连接,而不是 Active Directory 密码。
The SQL Server ODBC drivers for Linux from Microsoft are unable to determine instance names. Microsoft 的 SQL 服务器 ODBC 驱动程序 Linux 无法确定实例名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.