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

'DRIVER_NOT_FOUND', "No driver found for 'Teradata' #104

Closed mitchea5 closed 5 years ago

mitchea5 commented 6 years ago

Trying to connect using "system" I receive the following error:

teradata.api.InterfaceError: ('DRIVER_NOT_FOUND', "No driver found for 'Teradata'. Available drivers: PostgreSQL,MySQL") It appears to be looking at: /etc/odbcinst.ini, which has headings for MySQL and Postgres.

So...

export ODBCINST=/opt/teradata/client/ODBC_64/odbcinst.ini
export ODBCINI=/home/sb335c/IngestServer/etc/odbc.ini
export LD_LIBRARY_PATH=/opt/teradata/client/15.10/lib:/opt/teradata/client/15.10/tbuild/odbc/lib64:$LD_LIBRARY_PATH

Same error. Ok, lets hard code it:

udaExec = teradata.UdaExec(appName="blah",version="blah",odbcLibPath="/opt/teradata/client/ODBC_64/lib/libodbc.so") New error:

InterfaceError('DRIVER_NOT_FOUND', "No driver found for 'Teradata'. Available drivers: ")

Perl dbi, pyodbc, and tdxodbc64 are able to connect without an issue.

escheie commented 6 years ago

Your configuration looks correct. Using your configuration I am not able to reproduce the problem. What OS and Teradata ODBC driver version are you using?

mitchea5 commented 6 years ago

opt/teradata/client/15.10/bin$ tdxodbc64

Enter Data Source Name: xxxxx Enter UserID: yyyyy Enter Password:

Connecting with SQLConnect(DSN=xxxxx,UID=yyyyy,PWD=*)...

.....ODBC connection successful.

ODBC version = -03.52.0000- DBMS name = -Teradata- DBMS version = -16.20.0701 16.20.07.01- Driver name = -tdata.so- Driver version = -15.10.01.00- Driver ODBC version = -03.51-

Red Hat 4.8.5-11

Some other info:

odbc.ini

[ODBC]

IANAAppCodePage=4

InstallDir=/opt/teradata/client/15.10/tbuild/odbc Trace=0 TraceFile=odbctrace.out TraceDll=/opt/teradata/client/15.10/tbuild/odbc/lib64/_Ttrc27.so

[xxxxx] Driver=/opt/teradata/client/ODBC_64/lib/tdata.so Description=Teradata ODBC CharacterSet=UTF8 DBCName=xxxxx EnableDataEncryption=Yes EnableLOBs=Yes EnableReconnect=No IntegratedSecurity=No LoginTimeout=20 MapCallEscapeToExec=No MaxRespSize=1048576 PortNumber=1025 PrintOption=N ProcedureWithSplSource=Y ShowSelectableTables=Yes DSNTraceEnable=NO DSNTraceFilePath=/home/sb335c/IngestServer/bin/DSNTrace.log DSNTraceLineNumbers=NO DSNTraceFileMaxSize=100000000 DSNTraceOverwrite=YES

IANAAPPCODEPAGE=4

Trace=0 TraceDLL=/opt/teradata/client/15.10/lib/odbctrac.so TraceFile=/home/sb335c/trace.log EnableExtendedStmtInfo=Yes

ODBCTraceFlush=1

EnableLegacyParser=No

In addition, unixODBC is installed (can't get rid of it).

escheie commented 6 years ago

When I set InstallDir=/opt/teradata/client/15.10/tbuild/odbc, I see the same problem.

If I set InstallDir=/opt/teradata/client/ODBC_64, then it works.

You might try using provided odbc.ini, just to see if it gets you past the error:

export ODBCINI=/opt/teradata/client/ODBC_64

mitchea5 commented 6 years ago

I've commented out everything but: export ODBCINI=/opt/teradata/client/ODBC_64 And get the original error message teradata.api.InterfaceError: ('DRIVER_NOT_FOUND', "No driver found for 'Teradata'. Available drivers: PostgreSQL,MySQL")

If I add: export ODBCINSTINI=/opt/teradata/client/ODBC_64

Then the error message changes so it can't find the two drivers:

InterfaceError('DRIVER_NOT_FOUND', "No driver found for 'Teradata'. Available drivers: ")

Here is the default odbcinst.ini

[ODBC DRIVERS]
Teradata=Installed

[Teradata]
Driver=/opt/teradata/client/ODBC_64/lib/tdata.so
APILevel=CORE
ConnectFunctions=YYY
DriverODBCVer=3.51
SQLLevel=1

And the default odbc.ini

[ODBC]
InstallDir=/opt/teradata/client/ODBC_64
Trace=0
TraceDll=/opt/teradata/client/ODBC_64/lib/odbctrac.so
TraceFile=/usr/joe/odbcusr/trace.log
TraceAutoStop=0

[ODBC Data Sources]
testdsn=tdata.so

[testdsn]
Driver=/opt/teradata/client/ODBC_64/lib/tdata.so
Description=Teradata database
DBCName=
LastUser=
Username=
Password=
Database=
DefaultDatabase=
mitchea5 commented 6 years ago

Issue #43 has a similar problem, so I tried setting:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/teradata/client/15.10/lib64:/opt/teradata/client/ODBC_64/lib

And it didn't help.

mitchea5 commented 6 years ago

In my odbc.ini if I setup:

`InstallDir=/opt/teradata/client/ODBC_64

Trace=1

TraceFile=odbctrace.out

TraceDll=/opt/teradata/client/ODBC_64/lib/odbctrac.so ` As well as:

myDSN=tdata.so

in [ODBC Data Sources]

And then run tdxodbc64 and do a few queries, the trace file shows up, but if I do it in pyodbc I get no trace output, and PyTd gives the error:

Check that the ODBC driver is installed and the ODBCINI or ODBCINST environment variables are correctly set.

It's almost like python isn't respecting the odbc.ini file location. If I print out the ODBCINI in my python script, it shows the correct location.

bluberdiblub commented 5 years ago

Hi, I had the same issue today and found a solution to it. Please go to /usr/lib64 and check the following two symlinks:

lrwxrwxrwx 1 root root 20 Oct 18 10:56 libodbcinst.so -> libodbcinst.so.2.0.0 lrwxrwxrwx 1 root root 20 Oct 18 10:56 libodbcinst.so.2 -> libodbcinst.so.2.0.0

If they don't point to teradata, it will not work! They should point to the teradata odbc installation dir:

Fix (use at your own risk, without any warrenty) ;):

sudo rm /usr/lib64/libodbc.so sudo rm /usr/lib64/libodbcinst.so sudo ln -s /opt/teradata/client/16.20/lib64/libodbc.so /usr/lib64/libodbc.so sudo ln -s /opt/teradata/client/16.20/lib64/libodbcinst.so /usr/lib64/libodbcinst.so

The result:

lrwxrwxrwx 1 root root 47 Oct 25 20:10 libodbcinst.so -> /opt/teradata/client/16.20/lib64/libodbcinst.so lrwxrwxrwx 1 root root 43 Oct 25 20:10 libodbc.so -> /opt/teradata/client/16.20/lib64/libodbc.so

And voilá, the connection to Teradata should be running smooth as butter!

mitchea5 commented 5 years ago

I've migrated to the teradatasql module which uses the call level interface and does not rely on odbc. https://pypi.org/project/teradatasql/

HerculesGomez commented 4 years ago

Had the same issue. Tried many of the above but nothing worked. I removed anaconda and installed python36 and it is working now on oracle linux.

This is all I have in my .bash_profile: export ODBCINI=/opt/teradata/client/ODBC_64/odbc.ini

And then the contents of /opt/teradata/client/ODBC_64/odbc.ini are: [ODBC Drivers] Teradata Database ODBC Driver 16.20=Installed

[Teradata Database ODBC Driver 16.20] Description=Teradata Database ODBC Driver 16.20 Driver=/opt/teradata/client/ODBC_64/lib/tdataodbc_sb64.so CPTimeout=60

[ODBC] InstallDir=/opt/teradata/client/ODBC_64 Trace=no Pooling=yes

[ODBC Data Sources] Teradata ODBC DSN=Teradata Database ODBC Driver 16.20

[TDP6] Description=Teradata Database ODBC Driver 16.20

Driver: The location where the ODBC driver is installed to.

Driver=/opt/teradata/client/ODBC_64/lib/tdataodbc_sb64.so

Required: These values can also be specified in the connection string.

DBCName1= UID= PWD=

Hope this helps!

rajgit108 commented 3 years ago

Hello @HerculesGomez

I also have the same version of Teradata (16.20) installed in a Linux server. I changed my ODBC just like what you have posted.

I am trying to connect to Teradata via sqlalchemy's create_engine.

td_engine = create_engine('teradata://uid:psswd@host:22/') per an example I had found elsewhere.

I am getting the same DRIVER_NOT_FOUND error.

Could you please post how you are connecting to Teradata?

Thank you, Raj

bluberdiblub commented 3 years ago

Hi. So first of all sorry for reviving an old thread, but I think this solution may help some.

Please check the symlinks

I.e., the symlinks should be as follows: /usr/lib64/libodbcinst.so --> /opt/teradata/client/16.20/lib64/libodbcinst.so /usr/lib64/libodbc.so --> /opt/teradata/client/16.20/lib64/libodbc.so

What apparently happens is you install the Teradata ODBC driver and the symlinks are set correctly. But at the same time a different package also installed ODBC drivers and resets the symlink to point to a different library.

rajgit108 commented 3 years ago

I have it working now.

I had to install a Teradata dialect teradatasqlalchemy and the below syntax to connect to Teradata now works.

import sqlalchemy import create_engine eng = create_engine('teradatasql://username:password@hostname')