I am trying to use pymssql to connect to a SQL Server 2012 database running on Windows Server 2008.
db = pymssql.connect(host='xxx',user='xxx',password='xxx',database='xxx')
However, I am getting the following error:
OperationalError: (20017, 'DB-Lib error message 20017, severity 9:\nUnexpected EOF from the server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed\n')
The full error is:
Traceback (most recent call last):
File "XXX.py", line 2, in <module>
conn = pymssql.connect(host = 'XXX.com', user = 'xxx', password = 'xxx', database = 'xxx')
File "pymssql.pyx", line 556, in pymssql.connect (pymssql.c:7990)
raise OperationalError(e[0])
OperationalError: (20017, '\xa0\xff\xaf\x02\x90_\x8d\x02L\xd6\xa7\x02\xda\xad;DB-Lib error message 20017, severity 9:\nUnexpected EOF from the server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed\n')
Could someone help me figure out what's going on?
I would guess that it might be a total connection fail. I know it says 'EOF' but sometimes error messages like that are misleading.
I'd see if you can ping the host firstly from where you are running the script.
Secondly I'd see if you can get a tcp connection on the port you're using.
I've heard of EOF errors on http connections, when you connect with https to an http port. I'm not sure if that applies here.
This came up on google. It might help:
http://sourceforge.net/projects/pymssql/forums/forum/124111/topic/1672338
If all of the above is working, I'd double check the username and password are correct; perhaps even create a new user.
Finally, I'd check to see if the client library and the server library versions are compatible.
I hope this helps.