pypyodbc.Error: (u'IM002', u'[IM002] [unixODBC][Driver Manag

This is the place for queries that don't fit in any of the other categories.

pypyodbc.Error: (u'IM002', u'[IM002] [unixODBC][Driver Manag

Postby gresemonkei » Thu Sep 12, 2013 8:51 pm

Hello all, Thank you for seeing this. Obviously I am new here. I get the following error when I run the code. Where am I going wrong?

I am trying to connect to a SQL Server database on windows machine from a linux machine. I am running the script on Linux box.

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

Code: Select all
#!/usr/bin/env python

import pypyodbc

db_info = {
   "server" : "servername",
   "database" : "databasename",
   "user" : "sqlusername",
   "password" : "sqlpassword"
}

connection_string = "DRIVER={FreeTDS};" + "SERVER={0[server]};UID={0[user]};PWD={0[password]};DATABASE={0[database]}".format(db_info)
#connection_string = "DRIVER={FreeTDS};" + "SERVER={0[server]};UID={0[user]};PWD={0[password]};DATABASE={0[database]}".format(db_info)

print connection_string
connection = pypyodbc.connect(connection_string)

query = "SELECT TOP 50 columnname FROM tablename"

cursor = connection.cursor()

cursor.execute(query)

for columnname in cursor.description:
   print column_name


Thanks for looking! Any help appreciated.

-Ben
Last edited by Yoriz on Thu Sep 12, 2013 9:06 pm, edited 1 time in total.
Reason: First post lock
gresemonkei
 
Posts: 1
Joined: Thu Sep 12, 2013 8:38 pm

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 3 guests