0

Im trying to run a script i wrote on a Ubuntu Server.

Im using pypyodbc to connect to a database on a server in the script, and it works great on Windows.

When im trying to run it on my Ubuntu Server i get the following error:

pypyodbc.Error: (u'IM002', u'[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified')

This is my connectionstring:

DRIVER = "DRIVER={SQL Server};"
SERVER = "SERVER=servername;"
UID = "UID=userid;"
PWD = "PWD=password;"
DATABASE = "DATABASE=database_name;"

connection = pypyodbc.connect(DRIVER + SERVER + DATABASE + UID + PWD)

What have i done wrong? Any thoughts?

Best Regards.

Stains
  • 97
  • 1
  • 12
  • 1
    Show us how you have tried to make the connection, so we have a chance to find out what can be wrong with it. – quantummind Nov 22 '16 at 15:27
  • I edited my original post, but here is the connectionstring: `DRIVER = "DRIVER={SQL Server};" SERVER = "SERVER=servername;" UID = "UID=userid;" PWD = "PWD=password;" DATABASE = "DATABASE=database_name;" connection = pypyodbc.connect(DRIVER + SERVER + DATABASE + UID + PWD)` Can´t seem to get the formating right in this comment. – Stains Nov 23 '16 at 07:46

1 Answers1

0

You probably do not have [SQL Server] section in your /etc/odbcinst.ini file. You should have something like this in it:

[SQL Server]
Driver=<driver so file name>
<other parameters>

The section name must be the same you used to set the DRIVER in your python program. You should choose an appropriate driver like freetds for that. Check http://www.unixodbc.org/doc/FreeTDS.html

quantummind
  • 2,086
  • 1
  • 14
  • 20