Teradata / PyTd

A Python Module to make it easy to script powerful interactions with Teradata Database in a DevOps friendly way.
MIT License
108 stars 43 forks source link

Unable to connect to Teradata using one of the Kernel #60

Closed sudipto84goswami closed 7 years ago

sudipto84goswami commented 7 years ago

Hi Team,

We have 2 Conda Environment namely Root and Default-Notebook. We have also installed Teradata using pip and this is working pretty fine from Default-Notebook but when we change the Kernel to Root it does not work. It throws error : DatabaseError: (0, '[I] [. Check that the ODBC driver is installed and the ODBCINI or ODBCINST environment variables are correctly set.')

The ODBCINI and ODBCINST environments are set proper and thus it works fine when we use it from Default-notebook.

Root Kernel : /app/install/jupyter/anaconda3 Default-Notebook: /app/install/jupyter/anaconda3/envs/default-notebook

It will be really helpful if you can help us on where to check the configurations or how to troubleshoot. In addition while installing Teradata, it never asked for which Kernel it will be installed.

Error Message: DatabaseErrorTraceback (most recent call last)

in () 5 udaExec = teradata.UdaExec(appName="HelloWorld", version="1.0",logConsole=True,configureLogging=False,odbcLibPath="/opt/teradata/client/15.10/lib/libodbc.so") 6 session = udaExec.connect(method="odbc",system="XXXX", port="1025", username='XZXX',password='XXX', ----> 7 database='NDW_JRNL_TABLES', autoCommit=False ) 8 sql_query="SELECT * FROM DBC.Tables sample 5;"; 9 print (sql_query) /app/install/jupyter/anaconda3/lib/python3.5/site-packages/teradata/udaexec.py in connect(self, externalDSN, dataTypeConverter, **kwargs) 181 odbcLibPath=self.odbcLibPath, 182 dataTypeConverter=dataTypeConverter, --> 183 **args)) 184 else: 185 raise api.InterfaceError( /app/install/jupyter/anaconda3/lib/python3.5/site-packages/teradata/tdodbc.py in __init__(self, dbType, system, username, password, autoCommit, transactionMode, queryBands, odbcLibPath, dataTypeConverter, driver, **kwargs) 430 lock.release() 431 try: --> 432 checkStatus(rc, hDbc=self.hDbc, method="SQLDriverConnectW") 433 except: 434 rc = odbc.SQLFreeHandle(SQL_HANDLE_DBC, self.hDbc) /app/install/jupyter/anaconda3/lib/python3.5/site-packages/teradata/tdodbc.py in checkStatus(rc, hEnv, hDbc, hStmt, method, ignore) 207 "and the ODBCINI or ODBCINST environment " 208 "variables are correctly set.") --> 209 raise DatabaseError(i[2], u"[{}] {}".format(i[0], msg), i[0]) 210 else: 211 logger.debug( DatabaseError: (0, '[I] [. Check that the ODBC driver is installed and the ODBCINI or ODBCINST environment variables are correctly set.') TD query : import sys sys.path.append('/app/install/jupyter/anaconda3/bin/') sys.path.append('/app/install/jupyter/anaconda3/lib/python3.5/site-packages/') import teradata udaExec = teradata.UdaExec(appName="HelloWorld", version="1.0",logConsole=True,configureLogging=False,odbcLibPath="/opt/teradata/client/15.10/lib/libodbc.so") session = udaExec.connect(method="odbc",system="XXX", port="1025", username='XXX',password='XXX', database='NDW_JRNL_TABLES', autoCommit=False ) sql_query="SELECT * FROM DBC.Tables sample 5;"; print (sql_query) output=None for row in session.execute(sql_query): output=row[0] print (output)
sudipto84goswami commented 7 years ago

This is resolved by providing the correct location of Teradata Library