In a recent zope project I’m obliged to use an mssql database. So I test first an installation with a windows server os. Everything is ok when I configure the good port (1433) and open tcpip connection in sql management and stop firewall.
But when I try to connect with pymssql in unix I have some problem.
When I launch a connection to mssql I have this error:
>>> _mssql.connect("host","user", "password") Traceback (most recent call last): File "<console>", line 1, in ? MssqlDatabaseException: DB-Lib error message 20009, severity 9: Unable to connect: Adaptive Server is unavailable or does not exist Net-Lib error during Operation now in progress Error 36 - Operation now in progress
Yahoo , I’m very happy.
In google , no good post about this problem, so I’m very desappointed. I know that pymssql on unix work with freedts which is an implementation of the protocol which use mssql.
When you install freedts you install also some utility. It’s located in bin. Some of itÂ named tsql. You can use it to test your connection. As pymssql is an wrapper to freedts (in unix) and if tsql don’t work I suppose pymssql also. So I try with this command and I have exactly the same results :
mac:bin yboussard$ ./tsql -H myip -p 1433 -U myuser locale is "fr_FR.UTF-8" locale charset is "UTF-8" Password: Msg 20017, Level 9, State -1, Server OpenClient, Line -1 Unexpected EOF from the server Msg 20002, Level 9, State -1, Server OpenClient, Line -1 Adaptive Server connection failed There was a problem connecting to the server
So I’m very again very happy and reassure that I’m in the good way.
In read documentation about freedts and we can debug connection in setting environment variable TDSDUMP=/tmp/freetds.log. So now when I launch an connection I log in freetds.log. I see in this file the tds version used by the connection and I see it was incorrect (tds version is 5) in accordance with that documentation.
So I use an another environnement variable to fix that :
And miracle , everything work with tsql. So I force version of tds in my ~/.freetds.conf in global section as this
[global] tds version = 7.0
And after that everything is ok in python. Yahoo!!. I hope that ticket will be useful for you.