3

I am trying to connect TD with Python in Linux.

I got this working on Windows:

import pyodbc
conn = pyodbc.connect('DRIVER={Teradata};DBCNAME=<HOST IP>;UID=<UID>;PWD=<UID>;QUIETMODE=YES;')
cursor = conn.cursor()
sql = 'select * from table_name'
cursor.execute(sql)
rows = cursor.fetchall()
conn.close()
print rows

Steps I followed to do it on Linux:

  1. Install pyodbc
  2. Install TeraGSS, tdicu, cliv2, piom, tdodbc
  3. Run the following:
import pyodbc
conn = pyodbc.connect('DRIVER={Teradata};DBCNAME=<HOST IP>;UID=<UID>;PWD=<UID>;QUIETMODE=YES;')

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

Am I missing any configuration step after installations?

Environment:

Python 2.6.6 (r266:84292, Oct 12 2012, 14:23:48) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2

1
  • This might be a good guide to check whether your setup is correct Commented Jun 19, 2014 at 6:31

1 Answer 1

2

The string you pass as DRIVER needs to

a) the name of a driver in your odbcinst.ini file or

b) the full path to the ODBC driver shared object.

As you are using the first method I'd suggest you run odbcinst -j to find out where your odbcinst.ini file is located and check if you've defined any drivers.

Driver sections start with [MYDRIVERNAME] so you should have a section starting [Teradata] and it should contain a keyword/value pair of something like driver = /path/to/teradata/driver/shared_object. If you have defined a [Teradata] driver then check the shared object pointed to with the "driver" keyword exists, is readable/executable by you and has no unresolved dependencies (run ldd on it).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.