3
votes

I successfully installed pyodbc module for python 2.7. However, when input the following code to connect to teradata,

import pyodbc conn = pyodbc.connect('DRIVER={Teradata};DBCNAME=<tdwc>;UID=<UID>;PWD=<UID>;QUIETMODE=YES;')

I got the following error;

Traceback (most recent call last): File "", line 1, in pyodbc.connect('DRIVER={Teradata};DBCNAME=;UID=;PWD=;QUIETMODE=YES;') Error: ('00000', '[00000] [iODBC][Driver Manager]dlopen(/Library/Application Support/teradata/client/ODBC/lib/tdata.dylib, 6): Library not loaded: libtdparse.dylib\n Referenced from: /Library/Application Support/teradata/client/ODBC/lib/tdata.dylib\n Reason: image not found (0) (SQLDriverConnect)')

What should I do to have this fixed? Any ideas?

1

1 Answers

3
votes

Basically pyodbc is not straight forward and gives good enough debugging time for developers. Follow the below steps,

You might have done them already, then just verify

  1. Install iodbc for mac http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/Downloads

  2. Install Teradata ODBC Driver for Mac OS X, http://downloads.teradata.com/download/connectivity/teradata-odbc-driver-for-mac-os-x

  3. Also install unixodbc for mac, “brew install unixodbc”

  4. Download pyodbc source and change the setup.py file as below,

 elif sys.platform == 'darwin':
    # OS/X now ships with iODBC.
    settings['libraries'].append('iodbc')
    settings['libraries'].append('odbc')

you will be adding the last line of including “odbc” for build Build and install pyodbc

  1. Setup the traditional LD_LIBRARY_PATH for mac as below ( I used TD version 15.00, you have to point to the one as you installed)

export DYLD_LIBRARY_PATH=/Library/Application\ Support/teradata/client/ODBC/lib:/Library/Application\ Support/teradata/client/15.00/lib/

  1. Export ODBCINI path

export ODBCINI=/Library/Application\ Support/teradata/client/15.00/odbc/odbc.ini

Now pyodbc cursor happily will fetch record sets for you