Connect to Microsoft SQL Server via pyODBC on Ubuntu

I have a problem connecting to an instance of Microsoft SQL Server with pyODBC on an Ubuntu (12.10) machine Ubuntu (12.10) .

The error I am returning is:

 pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data Source name not found, and no default driver specified (0) (SQLDriverConnect)') 

The am connection string is used for pyodbc:

 self.corpus_cnxn = pyodbc.connect('DRIVER={FreeTDS};SERVER=UKEDN-06880;DATABASE=db1;UID=user;PWD=pass') 

This is similar to working with pyODBC on Windows (you just need to change DRIVER to "SQL Server" instead of "FreeTDS"), and it works fine when I try to connect to an Ubuntu machine using the tsql tool from the terminal with the following command:

 tsql -S UKEDN-06880 -p 1433 -U user -P pass 

I can select any table without problems, it just does not work from pyODBC.

Any help or advice would be greatly appreciated, my Linux skills are weak and I am completely stuck, although since it works from tsql I feel very close!

+7
source share
2 answers

It looks like you got freeTDS to work correctly, since you can use tsql. Have you tried connecting to isql?

Take a look at howto for a detailed walkthrough. Part, I think, you need to install unixodbc a bit down the page.

+9
source

first form $ sudo apt-get install libmdbodbc1

edit the file /etc/odbcinst.ini as follows

 [Microsoft Access Driver (*.mdb)] Description = Microsoft Access Driver (*.mdb) Driver = /path/to/file/libmdbodbc.so Setup = /path/to/file/libtdsS.so CPTimeout = CPReuse = 

And the file /etc/odbc.ini

 [Microsoft Access Driver (*.mdb)] Description = SQL Server Driver = Microsoft Access Driver (*.mdb) Trace = No TraceFile = /tmp/mssodbc.log 
+2
source

All Articles