views:

293

answers:

3

There doesn't seem to be any great instructions for setting this up. Does anyone have any good instructions? I am a linux noob so be gentle. I did see another post that is similar, but no real answer.

I have a couple of problems.

  1. FreeTDS doesn't "seem" to be working. I am trying to connect and I get the following message using the "tsql" command: "Default database being set to databaseName There was a problem connecting to the server" but it doesn't mention what the problem is.

    1. The error I get when I try to connect using pyodbc is: "pyodbc.Error: ('08S01', '[08S01] [unixODBC][FreeTDS][SQL Server]Unable to connect: Adaptive Server is unavailable or does not exist (20009) (SQLDriverConnectW)')"

    2. I tried something similar with pymssql, but I ran into similar issues. I keep getting errors that I can't connect, but it doesn't tell me why.

A: 

Can you post your FreeTDS configuration? And which version of MS SQL Server are you using?

Lawrence Oluyede
This should have been a comment rather than an answer.
vog
+1  A: 

The following works if you configure the MS SQL server to allow remote TCP/IP connections and have an appropriate user to connect as.

You also need to be careful to set up the correct hostname for the db as reported by MS SQL.

import pymssql
connection = pymssql.connect(
            user = 'username', 
            password = 'password', 
            host = 'server', 
            database = 'database',
        )
cursor = connection.cursor()
cursor.execute('select * from db;')
rows = cursor.fetchall()
Michaelnt
A: 

That error suggests that the TDS version is not set right. You can set that in the configuration setting for FreeTDS. You don't mention which MSSQL version you are using. But, if you are using say 2005, setting 8.0 as the TDS version will work.

ayaz