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.

2
  • 3
    It seems pretty amazing that there isn't any clear cut solution to this. Commented Jul 6, 2010 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. Commented Aug 26, 2010 at 9:54

3 Answers 3

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()
Sign up to request clarification or add additional context in comments.

Comments

1

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

./configure --with-tdsver=8.0 --enable-msdblib

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.