6

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.

Community
  • 1
  • 1
Keith P
  • 2,150
  • 1
  • 18
  • 15
  • 3
    It seems pretty amazing that there isn't any clear cut solution to this. – Keith P Jul 06 '10 at 21:08
  • I guess it is because nobody was able to reproduce your problem. You might have to do further analysis on your system, such as setting up an empty "dummy" MSSQL database and checking whether the issue is still there. Then, provide a summary on what exactly your test setup is composed of. That way, others could spot issues in your setup, or try a similar setup on their own machines. – vog Aug 26 '10 at 09:54

3 Answers3

2

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
  • 166
  • 4
1

When building FreeTDS (http://www.freetds.org/userguide/config.htm):

./configure --with-tdsver=8.0 --enable-msdblib
kermatt
  • 1,585
  • 2
  • 16
  • 36
0

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
  • 10,406
  • 6
  • 33
  • 48