简体   繁体   English

Python pymssql:Adaptive Server连接失败

[英]Python pymssql: Adaptive Server connection failed

I try to connect Azure SQL using python, but get next error: 我尝试使用python连接Azure SQL,但得到下一个错误:

File "pymssql.pyx", line 641, in pymssql.connect (pymssql.c:10824)
pymssql.OperationalError: (20002, 'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (myserver:1433)\n')

freetds.conf: freetds.conf:

[global]
        # TDS protocol version
        tds version = 7.4

        # Whether to write a TDSDUMP file for diagnostic purposes
        # (setting this to /tmp is insecure on a multi-user system)
        dump file = /tmp/freetds.log
;       debug flags = 0xffff

        # Command and connection timeouts
;       timeout = 10
;       connect timeout = 10

        # If you get out-of-memory errors, it may mean that your client
        # is trying to allocate a huge buffer for a TEXT field.
        # Try setting 'text size' to a more reasonable limit
        text size = 64512

If I try connect use tsql - connect success! 如果我尝试连接使用tsql - 连接成功!

I try recompiled freetds with params: 我尝试用params重新编译freetds:

./configure --enable-msdblib --enable-threadsafe --enable-sybase-compat --with-tdsver=7.4 --with-openssl=/usr/bin

I'm using this manual https://msdn.microsoft.com/en-us/library/mt694094(v=sql.1).aspx 我正在使用本手册https://msdn.microsoft.com/en-us/library/mt694094(v=sql.1).aspx

@Alximik Per my experience, I don't think recompiling freetds by self is necessary. @Alximik根据我的经验,我不认为自我重新编译freetds是必要的。 For the issue, I think the issue was caused by your configuration for freetds.conf , please see my answer for the solved SO thread pymssql: Connection to the database only works sometimes and the sample configuration content below. 对于这个问题,我认为问题是由你的freetds.conf配置引起的,请参阅我解决的SO线程pymssql的答案:数据库连接有时只能工作 ,下面是示例配置内容。

host = <database_name>.database.windows.net
port = 1433
tds version = 7.3

Meanwhile, you can refer to http://www.freetds.org/userguide/freetdsconf.htm to configure it. 同时,您可以参考http://www.freetds.org/userguide/freetdsconf.htm进行配置。

I solve it after make from source pymssql and freetds (with option in previous post and set tds version=7.3 in global config). 我在源pymssql和freetds之后解决它(在之前的帖子中有选项,在全局配置中设置tds version = 7.3)。 Pymssql make from source use command "python setup.py build" and next for install in system "python setup.py install" Pymssql从源代码使用命令“python setup.py build”,然后在系统“python setup.py install”中安装

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM