First, you need to install some packages.

$ sudo aptitude install unixodbc unixodbc-dev freetds-dev sqsh tdsodbc

With FreeTDS installed configure it like this:



# host configuration is in /etc/odbcinst.ini

tds version = 7.0

Testing FreeTDS is not too hard:

$ sqsh -S myServer -U USERNAME -P PASSWORD

Next up it’s necessary to configure ODBC:

Description     = TDS driver (Sybase/MS SQL)  
Driver          = /usr/lib/odbc/  
Setup           = /usr/lib/odbc/  
CPTimeout       =  
CPReuse         =  
FileUsage       = 1 

Driver          = FreeTDS  
Description     = ODBC connection via FreeTDS  
Trace           = No  
Servername      = myServer  
Database        = DATABASENAME  

Now you want to install pyodbc

$ easy_install pyodbc

and use it in python:

import pyodbc  
cnxn = pyodbc.connect('DSN=myServer;UID=USERNAME;PWD=PASSWORD')

See: on-ubuntu/