Connect Python to Teradata in mac with pyodbc

后端 未结 1 475
星月不相逢
星月不相逢 2021-01-20 23:28

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

相关标签:
1条回答
  • 2021-01-20 23:45

    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

    0 讨论(0)
提交回复
热议问题