Am having an issue connecting to a Microsoft SQL Server instance from pyODBC
within an Ubuntu (12.10)
machine.
The error I am getting back is:
pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data Source name not found, and no default driver specified (0) (SQLDriverConnect)')
The connection string am using for pyodbc is:
self.corpus_cnxn = pyodbc.connect('DRIVER={FreeTDS};SERVER=UKEDN-06880;DATABASE=db1;UID=user;PWD=pass')
This seems to work fine from pyODBC within Windows (just need to change the DRIVER to 'SQL Server' instead of 'FreeTDS'), and it work fine when I try to connect from the 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 with no issues, it just doesn't seem to work from within pyODBC.
Any help or advice will be much appreciated, my Linux skills are uber weak and am totally stuck, although since it works from tsql I get the feeling that am very close!
Install the SQL Server command-line toolsImport the public repository GPG keys. Register the Ubuntu repository. Update the sources list and run the installation command with the unixODBC developer package. For more information, see Install the Microsoft ODBC driver for SQL Server (Linux).
Use the following steps to install the mssql-tools on SUSE Linux Enterprise Server. Add the Microsoft SQL Server repository to Zypper. Install mssql-tools with the unixODBC developer package. Optional: Add /opt/mssql-tools/bin/ to your PATH environment variable in a bash shell.
pyodbc and Linux Easysoft ODBC drivers have been tested with pyodbc 2.0+, 2.1+, 3.0+, 4.0+ on RedHat, Ubuntu and Debian GNU/Linux, but should work with any recent 32-bit or 64-bit Linux distribution — CentOS, Fedora, Kubuntu, Mandrake/Mandriva, OpenSUSE/SUSE, RedHat Enterprise Linux (RHEL), Slackware and so on.
It looks like you have gotten freeTDS to work correctly since you can use tsql. Have you tried to connect with isql?
Look at this howto for a detailed walk through. The part I think you need is in setting up unixodbc a little ways down the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With