Skip to Content.
Sympa Menu

freetds - [freetds] Way to get connection params on failure?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Marc Abramowitz <msabramo AT gmail.com>
  • To: FreeTDS mailing list <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Way to get connection params on failure?
  • Date: Thu, 2 Jan 2014 18:31:41 -0800

Recently a well-known Python database module developer was using pymssql
and it wasn't working for him because he was connecting to a SQL Server on
a non-standard port and he had put this port in an entry in his
freetds.conf and was able to connect with tsql, but he was getting errors
when trying to connect with pymssql, which turned out to be because pymssql
calls DB-LIB functions that don't end up consulting freetds.conf to get the
port and so the connect was failing for him, whereas it passed with tsql,
so he thought that he had discovered a bug in pymssql.

The solution was simple. By adding an explicit `port` argument to his
Python code, stuff worked. But we only discovered this after I advised him
about TDSDUMPCONFIG and such and ultimately figured it out.

The takeaway for me and he said this as well, is that it would be nice if
there were better error messages on connection failure. Either from pymssql
or FreeTDS. This would help people diagnose their connection issues much
quicker.

Currently a failed connection results in an error like this:

Error 20009 (severity 9):
Unable to connect: Adaptive Server is unavailable or does not exist
OS error 61, "Connection refused"

Note that it doesn't say what IP address, port, etc. it was trying to
connect to.

Is there a way to either augment the default FreeTDS error messages --
e.g.: "Connection refused to 127.0.0.1:1433" or DB-API calls that, given
the dbproc or such, will give the IP address, port, etc. so that I can
print them out in my error handler?

Marc




Archive powered by MHonArc 2.6.24.

Top of Page