1
votes

I am unable to achieve teradata connectivity using python. I have anaconda set up 4.3.1(64-bit) with python 2.7.13. Further i installed teradata odbc client driver for 16.20 and configured the odbc.ini file with user DSN details.

I have tried the options mentioned in this article - https://github.com/Teradata/PyTd/issues/43 https://github.com/Teradata/PyTd/issues/89

import teradata
  import os, sys
  os.environ["ODBCINI"] ="/opt/teradata/client/16.20/odbc_64/odbc.ini"
  os.environ["O`enter code here`DBCINST"] ="/opt/teradata/client/16.20/odbc_64/odbcinst.ini"
  os.environ["LD_LIBRARY_PATH"] ="/opt/teradata/client/16.20/odbc_64/lib"

udaExec = teradata.UdaExec (appName="HelloWorld", version="1.0", odbcLibPath="/opt/teradata/client/16.20/odbc_64/lib/tdataodbc_sb64.so")
session = udaExec.connect(method="odbc", system="tdprod", username="xxxxx", password="yyyyy")
for row in session.execute("SELECT GetQueryBand();"):
print(row)

Below is the execution log and error message of this script -

[servername@python]$ python test_teradata.py
Traceback (most recent call last):
File "test_teradata.py", line 17, in 
session = udaExec.connect(method="odbc", system="tdprod", username="xxxxx", password="yyyyy")
File "/.../.../anaconda/lib/python2.7/site-packages/teradata/udaexec.py", line 183, in connect
**args))
File "/.../.../anaconda/lib/python2.7/site-packages/teradata/tdodbc.py", line 421, in __init__init(odbcLibPath)
File "/.../.../anaconda/lib/python2.7/site-packages/teradata/tdodbc.py", line 367, in init initFunctionPrototypes()
File "/.../.../anaconda/lib/python2.7/site-packages/teradata/tdodbc.py", line 298, in initFunctionPrototypes prototype(odbc.SQLDrivers, SQLHANDLE, SQLUSMALLINT, PTR(SQLCHAR),
File "/.../.../anaconda/lib/python2.7/ctypes/init.py", line 375, in __getattr__func = self.getitem(name)
File "/.../.../anaconda/lib/python2.7/ctypes/init.py", line 380,in __getitem__func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /opt/teradata/client/16.20/odbc_64/lib/tdataodbc_sb64.so: undefined symbol: SQLDrivers
1

1 Answers

0
votes

If supplied, the odbcLibPath should point to the ODBC Driver Manager (libodbc.so), not the ODBC Driver itself.

If the wrong driver is being selected, then add explicit driver= parameter to the connect arguments, e.g. driver="Teradata Database ODBC Driver 16.20".`