Connect Python to Teradata in mac with pyodbc

匿名 (未验证) 提交于 2019-12-03 02:34:02

问题:

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:

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



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!