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

teradata.api.DatabaseError: (0, u'[I] [') #43

Closed JMetai closed 8 years ago

JMetai commented 8 years ago

Throwing errors when I run below code, any help is appreciated.

import teradata

udaExec = teradata.UdaExec (appName="Test", version="1.0",logConsole=False) session = udaExec.connect(method="odbc", system="teradatahost", username="user1", password="user1pass"); for row in session.execute("SELECT GetQueryBand()"): print(row)

Traceback (most recent call last): File "print.py", line 4, in session = udaExec.connect(method="odbc", system="teradatahost", username="user1", password="user1pass"); File "/root/miniconda2/envs/data_prod/lib/python2.7/site-packages/teradata/udaexec.py", line 181, in connect args)) File "/root/miniconda2/envs/data_prod/lib/python2.7/site-packages/teradata/tdodbc.py", line 374, in init** checkStatus(rc, hDbc=self.hDbc, method="SQLDriverConnectW") File "/root/miniconda2/envs/data_prod/lib/python2.7/site-packages/teradata/tdodbc.py", line 206, in checkStatus raise DatabaseError(i[2], u"[{}] {}".format(i[0], msg), i[0]) teradata.api.DatabaseError: (0, u'[I] [')

escheie commented 8 years ago

Please check the following three things:

1) unixodbc is not installed. 2) The Teradata ODBC driver is installed. 3) Check that the ODBCINST environment variable is set to odbcinst.ini file included in the Teradata ODBC driver or that the ODBCINI environment variable is set to an odbc.ini file that includes an InstallDir field that correctly references the install directory of the Teradata ODBC Driver.

Please let me know what you find out. Because the error the python module gets back is cryptic, I'd like to be able to replace this message with something more descriptive of what the problem is so that others that may hit the issue can get past it.

JMetai commented 8 years ago

Thanks for the solution. ODBC environment variables were incorrectly set, after setting them correctly. Issue fixed. I have another question, does this module use bteq or fastexport or mload utility to load data into teradata?

escheie commented 8 years ago

The module only either uses ODBC or the Teradata REST API.

escheie commented 8 years ago

Adding code to check for cryptic error returned from OBDC driver manager and instead returning an error message with the following details:

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

danbanker commented 8 years ago

Hi escheie,

I'm encountering this new error message and have attempted the steps listed above, but with no success.

Is the above stating that I cannot have unixODBC installed?

I did the following:

ODBCINI=/opt/teradata/client/ODBC_32/odbc.ini 
export ODBCINI
ODBCINST=/opt/teradata/client/ODBC_32/odbcinst.ini
export ODBCINST

and checked that these now exist:

env|grep ODBCINI
env|grep ODBCINST

I have even tried to use their 64-bit versions, but nothing is working.

Is there a way to further debug this issue?

OUTPUT:

Traceback (most recent call last):
  File "OUTPUT_SQL_TO_FILE.py", line 16, in <module>
    username="myuser", password="mypass");
  File "/CS_JOBS/PRODUCTION_JOBS/python/env_2/lib/python2.7/site-packages/teradata/udaexec.py", line 183, in connect
    **args))
  File "/CS_JOBS/PRODUCTION_JOBS/python/env_2/lib/python2.7/site-packages/teradata/tdodbc.py", line 374, in __init__
    checkStatus(rc, hDbc=self.hDbc, method="SQLDriverConnectW")
  File "/CS_JOBS/PRODUCTION_JOBS/python/env_2/lib/python2.7/site-packages/teradata/tdodbc.py", line 206, in checkStatus
    raise DatabaseError(i[2], u"[{}] {}".format(i[0], msg), i[0])
teradata.api.DatabaseError: (0, u'[I] [. Check that the ODBC driver is installed and the ODBCINI or ODBCINST environment variables are correctly set.')

SCRIPT:

import teradata

udaExec = teradata.UdaExec (appName="HelloWorld", version="1.0",
        logConsole=False)

session = udaExec.connect(method="odbc", system="TDPROD",
        username="myuser", password="mypass");

for row in session.execute("SELECT current_date as currdt"):
    print(row)

ODBCINST:

[ODBC DRIVERS]
Teradata=Installed

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

ODBCINI:

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

[ODBC Data Sources]
testdsn=tdata.so

[testdsn]
Driver=/opt/teradata/client/ODBC_32/lib/tdata.so
Description=Teradata database
DBCName=
LastUser=
Username=
Password=
Database=
DefaultDatabase=

[TDPROD]
Driver=/opt/teradata/client/ODBC_32/lib/tdata.so
Description=Teradata database
DBCName=
LastUser=
Username=
Password=
Database=TDPROD
DefaultDatabase=
escheie commented 8 years ago

The module loads "libodbc.so" by default without a path, leaving it up to the system to load it from the system library path . If unixodbc is installed, then the libodbc.so implementation that gets loaded could actually be the unixodbc version, and not the version that ships with the Teradata ODBC driver. You could try setting the "odbcLibPath" in your configuration or as parameter to UdaExec to the exact path of the version of libodbc.so that ships wit the odbc driver. E.g.

udaExec = teradata.UdaExec(odbcLibPath="/opt/teradata/client/15.10/lib/libodbc.so")
danbanker commented 8 years ago

Thanks for your reply. I tried 32-bit then 64-bit and got the following errors. ODBCINI and ODBCINST are the same as in my last post. I changed all 32's to 64's across the files and script for the 64-bit test. The output looks like I'm getting closer, but still missing something.

ODBCINI=/opt/teradata/client/ODBC_32/odbc.ini 
export ODBCINI
ODBCINST=/opt/teradata/client/ODBC_32/odbcinst.ini
export ODBCINST

SCRIPT:

import teradata

udaExec = teradata.UdaExec (odbcLibPath="/opt/teradata/client/15.00/odbc_32/lib/libodbc.so",
        appName="HelloWorld", version="1.0",logConsole=False)

session = udaExec.connect(method="odbc", system="TDPROD",
        username="myuser", password="mypass");

for row in session.execute("SELECT current_date as currdt"):
    print(row)

32-bit OUTPUT:

Traceback (most recent call last):
  File "OUTPUT_SQL_TO_FILE.py", line 16, in <module>
    username="myuser", password="mypass");
  File "/CS_JOBS/PRODUCTION_JOBS/python/env_2/lib/python2.7/site-packages/teradata/udaexec.py", line 183, in connect
    **args))
  File "/CS_JOBS/PRODUCTION_JOBS/python/env_2/lib/python2.7/site-packages/teradata/tdodbc.py", line 360, in __init__
    init(odbcLibPath)
  File "/CS_JOBS/PRODUCTION_JOBS/python/env_2/lib/python2.7/site-packages/teradata/tdodbc.py", line 317, in init
    initOdbcLibrary(odbcLibPath)
  File "/CS_JOBS/PRODUCTION_JOBS/python/env_2/lib/python2.7/site-packages/teradata/tdodbc.py", line 291, in initOdbcLibrary
    odbc = ctypes.cdll.LoadLibrary(odbcLibPath)
  File "/usr/lib64/python2.7/ctypes/__init__.py", line 438, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib64/python2.7/ctypes/__init__.py", line 360, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /opt/teradata/client/15.00/odbc_32/lib/libodbc.so: wrong ELF class: ELFCLASS32

64-bit OUTPUT:

Traceback (most recent call last):
  File "OUTPUT_SQL_TO_FILE.py", line 16, in <module>
    username="myuser", password="mypass");
  File "/CS_JOBS/PRODUCTION_JOBS/python/env_2/lib/python2.7/site-packages/teradata/udaexec.py", line 183, in connect
    **args))
  File "/CS_JOBS/PRODUCTION_JOBS/python/env_2/lib/python2.7/site-packages/teradata/tdodbc.py", line 374, in __init__
    checkStatus(rc, hDbc=self.hDbc, method="SQLDriverConnectW")
  File "/CS_JOBS/PRODUCTION_JOBS/python/env_2/lib/python2.7/site-packages/teradata/tdodbc.py", line 206, in checkStatus
    raise DatabaseError(i[2], u"[{}] {}".format(i[0], msg), i[0])
teradata.api.DatabaseError: (0, u'[IM002] [DataDirect][ODBC lib] Data source name not found and no default driver specified')
andrewtmendoza commented 8 years ago

Hi there - I'm having the same issue as @danbanker.

After changing my UdaExec to: udaExec = teradata.UdaExec (odbcLibPath="/opt/teradata/client/15.10/lib64/libodbc.so", appName="HelloWorld", version="1.0",logConsole=False)

I receive the following error: OSError: libddicu27.so: cannot open shared object file: No such file or directory

escheie commented 8 years ago

@danbanker - If you are using a 64-bit version of Python, then you will want to point to the 64-bit version of the ODBC driver, that is why you got that error loading the 32-bit version.

I tried to reproduce the error you are now seeing when loading the 64-bit version. I only see that message when I'm using the "dsn" option to connect instead of the "system" option, and only when the "dsn" option is referring to a data source name that is not in my odbc.ini file. Is it possible you switched to from using the "system" argument to the "dsn" argument after posting your script? Have you been able to get past that error?

@andrewtmendoza - Do you see "libddicu27.so" in "/opt/teradata/client/15.10/lib64". I see that file in my 15.10 ODBC install. If not, then you may need to reinstall the Teradata ODBC driver. If it is there, then you may need to add that directory to the library load path. Try adding that directory to the LD_LIBRARY_PATH environment variable. E.g.

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

danbanker commented 8 years ago

@escheie - Sorry for the late reply. My code is definitely using system="TDPROD" vs. dsn="TDPROD". If I do change it to use DSN, the same error is thrown. It is as if perhaps the "system" argument is not getting passed at all, which is making it default to DSN. I'm stumped on this unfortunately.

COMMANDS:

ODBCINI=/opt/teradata/client/ODBC_64/odbc.ini 
export ODBCINI
ODBCINST=/opt/teradata/client/ODBC_64/odbcinst.ini
export ODBCINST

SCRIPT:

import teradata

udaExec = teradata.UdaExec (odbcLibPath="/opt/teradata/client/15.00/odbc_64/lib/libodbc.so",
        appName="HelloWorld", version="1.0",logConsole=False)

session = udaExec.connect(method="odbc", system="TDPROD",
        username="myuser", password="mypass");

for row in session.execute("SELECT current_date as currdt"):
    print(row)

OUTPUT:

Traceback (most recent call last):
  File "test_teradata.py", line 7, in <module>
    username="myuser", password="mypass");
  File "/CS_JOBS/PRODUCTION_JOBS/python/env_1/lib/python2.7/site-packages/teradata/udaexec.py", line 183, in connect
    **args))
  File "/CS_JOBS/PRODUCTION_JOBS/python/env_1/lib/python2.7/site-packages/teradata/tdodbc.py", line 374, in __init__
    checkStatus(rc, hDbc=self.hDbc, method="SQLDriverConnectW")
  File "/CS_JOBS/PRODUCTION_JOBS/python/env_1/lib/python2.7/site-packages/teradata/tdodbc.py", line 206, in checkStatus
    raise DatabaseError(i[2], u"[{}] {}".format(i[0], msg), i[0])
teradata.api.DatabaseError: (0, u'[IM002] [DataDirect][ODBC lib] Data source name not found and no default driver specified')

/opt/teradata/client/ODBC_64/odbcinst.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
TDPROD=tdata.so

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

[TDPROD]
Driver=/opt/teradata/client/ODBC_64/lib/tdata.so
Description=Teradata database
DBCName=
LastUser=
Username=
Password=
Database=
DefaultDatabase=

/opt/teradata/client/ODBC_64/odbc.ini

[ODBC DRIVERS]
Teradata=Installed

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

Does the below look correct? I'm thinking that it should be: libodbcinst.so => /opt/teradata/client/15.00/odbc_64/lib/libodbcinst.so Vs. /lib64/libodbcinst.so

ldd /opt/teradata/client/15.00/odbc_64/lib/libodbc.so
/opt/teradata/client/15.00/odbc_64/lib/libodbc.so: /lib64/libodbcinst.so: no version information available (required by /opt/teradata/client/15.00/odbc_64/lib/libodbc.so)
        linux-vdso.so.1 =>  (0x00007ffe935fd000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa9dc14c000)
        librt.so.1 => /lib64/librt.so.1 (0x00007fa9dbf43000)
        libodbcinst.so => /lib64/libodbcinst.so (0x00007fa9dbd31000)
        libddicu26.so => /lib64/libddicu26.so (0x00007fa9dae3a000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fa9dac35000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fa9da92c000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fa9da62a000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fa9da268000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fa9da052000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fa9dc614000)
        libltdl.so.7 => /lib64/libltdl.so.7 (0x00007fa9d9e48000)

I went ahead and added the following to my script, but still no luck:

os.environ["ODBCINI"] = "/opt/teradata/client/15.00/odbc_64/odbc.ini"
os.environ["ODBCINST"] = "/opt/teradata/client/15.00/odbc_64/odbcinst.ini"
os.environ["LD_LIBRARY_PATH"] = "/opt/teradata/client/15.00/odbc_64/lib:/opt/teradata/client/15.00/odbc_64/odbc.ini:/opt/teradata/client/15.00/odbc_64/odbcinst.ini"

print os.environ['ODBCINI']
print os.environ['ODBCINST']
print os.environ['LD_LIBRARY_PATH']
escheie commented 8 years ago

@danbanker - I was able to reproduce the error you're getting after installing unixODBC. Looks like you are right about it still linking to the wrong libraries. I was able to get past the error by setting LD_LIBRARY_PATH as follows:

[escheie@PyTd]# echo $ODBCINI
/opt/teradata/client/ODBC_64/odbc.ini
[escheie@PyTd]# export LD_LIBRARY_PATH=/opt/teradata/client/ODBC_64/lib
[escheie@PyTd]# python2.7 test.py 
cbonilla20 commented 8 years ago

Hi, following this error (it seems similar to my problem), my difference, is in this: ldd /opt/teradata/client/15.00/odbc_64/lib/libodbc.so

linux-vdso.so.1 => (0x00007ffe3a9c1000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa8310fa000) librt.so.1 => /lib64/librt.so.1 (0x00007fa830ef1000) libodbcinst.so => not found libddicu26.so => not found libdl.so.2 => /lib64/libdl.so.2 (0x00007fa830cec000) libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fa8309e6000) libm.so.6 => /lib64/libm.so.6 (0x00007fa830762000) libc.so.6 => /lib64/libc.so.6 (0x00007fa8303cd000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fa8301b7000) /lib64/ld-linux-x86-64.so.2 (0x00007fa8315c1000)

My error is OSError: /opt/teradata/client/15.10/lib64/libodbc.so: cannot open shared object file: No such file or directory

But as you can seem, the .so exists in the path with little suspicious differences than @danbanker post earlier.

UPDATE The error was the path to the .so. The problem now is libodbcinst.so: cannot open shared object file: No such file or directory.

I already set the enviroment LD_LIBRARY_PATH to $LD_LIBRARY_PATH;/opt/teradata/client/odbc_64/lib and configure back the .so

ldd /opt/teradata/client/15.00/odbc_64/lib/libodbc.so linux-vdso.so.1 => (0x00007ffdc1dbe000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff9e61f4000) librt.so.1 => /lib64/librt.so.1 (0x00007ff9e5feb000) libodbcinst.so => /usr/lib64/libodbcinst.so (0x00007ff9e5dc7000) libddicu26.so => /usr/lib64/libddicu26.so (0x00007ff9e4ed0000) libdl.so.2 => /lib64/libdl.so.2 (0x00007ff9e4ccb000) libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007ff9e49c5000) libm.so.6 => /lib64/libm.so.6 (0x00007ff9e4741000) libc.so.6 => /lib64/libc.so.6 (0x00007ff9e43ac000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007ff9e4196000) /lib64/ld-linux-x86-64.so.2 (0x00007ff9e66bb000)

Then, the problem now is: teradata.api.DatabaseError: (0, u'[IM003] [DataDirect][ODBC lib] Specified driver could not be loaded') This is running over an ORACLE Linux RHEL I think we got a bug here. Regards.

andrewtmendoza commented 8 years ago

@escheie - Thanks for your last tip. After adding that directory to the LD_LIBRARY_PATH environment variable, I am seeing the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/anaconda/lib/python2.7/site-packages/teradata/udaexec.py", line 172, in connect
    **args))
  File "/home/ubuntu/anaconda/lib/python2.7/site-packages/teradata/tdodbc.py", line 358, in __init__
    checkStatus(rc, hDbc=self.hDbc, method="SQLDriverConnectW")
  File "/home/ubuntu/anaconda/lib/python2.7/site-packages/teradata/tdodbc.py", line 194, in checkStatus
    raise DatabaseError(i[2], u"[{}] {}".format(i[0], i[1]), i[0])
teradata.api.DatabaseError: (0, u'[HY000] [Teradata][ODBC Teradata Driver] Loading the Teradata ICU Library Failed. USelDir Library returned an error. Error is: "/opt/teradata/client/15.10/.genuine_TTU" does not have the set-user-ID on execution bit set.')
danbanker commented 8 years ago

@escheie Thanks again for your help. After making the suggested change to the library path, I am able to successfully connect! Our server currently leverages unixODBC for other database connections, so couldn't remove it. Very glad that there is a workaround.

Ultimately, it seems that the last issue that was tripping me up was a general python issue where I could not find a way to successfully change the environmental variable within the script and have the same running script later leverage the new version of the variable.

In case anyone else encounters the same issue, my python script and odbc.ini remains the same format as my earlier post, however I kick it off using the following script:

run_script.sh

export ODBCINI=/opt/teradata/client/ODBC_64/odbc.ini
export ODBCINST=
export LD_LIBRARY_PATH=/opt/teradata/client/ODBC_64/lib

/my_python_path/python test_teradata.py
cbonilla20 commented 8 years ago

Hi @danbanker, I tried with your notes and my python script, and didn't work. Sure that your path without the teradata version directory works?

Regards C.

danbanker commented 8 years ago

@cbonilla20 - Best to post your error for @escheie to comment on. I read somewhere deep in the documentation that in order to be backwards/forwards compatible the uppercase higher-level ODBC_64 directory that is not within the version-numbered folder will in fact map to your version automatically. It seems to be the one that @escheie has pointed to as well in solving my problem. At the moment, i have ensured that the odbc.ini files match in both places nonetheless. If I had to guess though, if your installation is like mine, the LD_LIBRARY_PATH that you mentioned earlier looks to be missing capitalization of "ODBC_64" where Linux is case sensitive. Might want double check that that path is correct.

cbonilla20 commented 8 years ago

Should I open a new issue for my error? @danbanker @escheie Regards

escheie commented 8 years ago

@cbonilla20 - Yes, please. Please report all details of your environment (ODBC version, is unix-odbc installed and is it necessary, your environment variables, and the exact errors you are getting. If possible, it would be good if you could uninstall and reinstall the Teradata ODBC driver with the latest patched version just to be sure the environment is correctly installed.

mainephd commented 8 years ago

@andrewtmendoza Did you ever resolve your error? I am having the same exact error after properly setting the LD_LIBRARY_PATH variable and trying multiple file permissions.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/anaconda/lib/python2.7/site-packages/teradata/udaexec.py", line 172, in connect
    **args))
  File "/home/ubuntu/anaconda/lib/python2.7/site-packages/teradata/tdodbc.py", line 358, in __init__
    checkStatus(rc, hDbc=self.hDbc, method="SQLDriverConnectW")
  File "/home/ubuntu/anaconda/lib/python2.7/site-packages/teradata/tdodbc.py", line 194, in checkStatus
    raise DatabaseError(i[2], u"[{}] {}".format(i[0], i[1]), i[0])
teradata.api.DatabaseError: (0, u'[HY000] [Teradata][ODBC Teradata Driver] Loading the Teradata ICU Library Failed. USelDir Library returned an error. Error is: "/opt/teradata/client/15.10/.genuine_TTU" does not have the set-user-ID on execution bit set.')
andrewtmendoza commented 8 years ago

@mainephd No, I was unable to resolve it unfortunately.

escheie commented 8 years ago

@andrewtmendoza and @mainephd - I will post your issue to the ODBC support list to see if they know of any solutions. Have you tried setting the set-user-ID execution bit on that file to see if it resolved the problem?

escheie commented 8 years ago

@andrewtmendoza and @mainephd - Can you also provide environment details? OS, ODBC version, is unixODBC installed, etc.

mainephd commented 8 years ago

@escheie I am using the teradata module in Cloudfoundry

OS = https://hub.docker.com/r/cloudfoundry/cflinuxfs2/ ODBC = Teradata 15.10.01.03 which available is here UnixODBC = Not installed.

I am running in an environment where I can not chgrp nor chown the .genuine_TTU file. In the docker container I am able to recreate the issue and correct the issue once the file is owned by the root user and root group.

These set of permissions and ownership work

vcap@74886901804b:/app/vendored/teradata/client/15.10$ ll
total 28
drwxr-xr-x 6 vcap vcap 4096 Sep  8 02:18 ./
drwxr-xr-x 3 vcap vcap 4096 Sep  8 02:18 ../
drwxr-xr-x 2 vcap vcap 4096 Sep  8 02:18 etc/
---s--x--x 1 root root    1 Sep  8 02:18 .genuine_TTU*
drwxr-xr-x 2 vcap vcap 4096 Sep  8 02:18 include/
drwxr-xr-x 2 vcap vcap 4096 Sep  8 13:38 lib64/
drwxr-xr-x 5 vcap vcap 4096 Sep  8 13:38 odbc_64/
-rw-r--r-- 1 vcap vcap    0 Sep  8 02:18 ttu_softlinks_yes_1510
-rw-r--r-- 1 vcap vcap    0 Sep  8 02:18 ttu_updateETC_1510

These permissions and ownership do not work

vcap@74886901804b:/app/vendored/teradata/client/15.10$ ll
total 28
drwxr-xr-x 6 vcap vcap 4096 Sep  8 02:18 ./
drwxr-xr-x 3 vcap vcap 4096 Sep  8 02:18 ../
drwxr-xr-x 2 vcap vcap 4096 Sep  8 02:18 etc/
---s--x--x 1 vcap vcap    1 Sep  8 02:18 .genuine_TTU*
drwxr-xr-x 2 vcap vcap 4096 Sep  8 02:18 include/
drwxr-xr-x 2 vcap vcap 4096 Sep  8 13:38 lib64/
drwxr-xr-x 5 vcap vcap 4096 Sep  8 13:38 odbc_64/
-rw-r--r-- 1 vcap vcap    0 Sep  8 02:18 ttu_softlinks_yes_1510
-rw-r--r-- 1 vcap vcap    0 Sep  8 02:18 ttu_updateETC_1510
escheie commented 8 years ago

I heard back from the TTU install team. The .genuine_TTU file must be owned by root and have permission of 4111. When the tdicu package is installed, the permission is set to 4111 and owner:group is root:root so looks like the permissions may have been changed after install.

mainephd commented 8 years ago

@escheie Changing of file ownership is what happens by design with Cloud Foundry. Would the TTU team be open to making a change to the process that verifies the ownership to the .genuine_TTU file?

escheie commented 8 years ago

@mainephd Got it, I sent your request to the TTU install team, we'll see what they have to say.

escheie commented 8 years ago

@mainphd - Can you provide details how you deployed ODBC on the CloudFoundry docker image? The TTU team is trying to reproduce the issue to better understand it.

Thanks, -Eric

mainephd commented 8 years ago

@escheie This repository demonstrates how to recreate the error when running in Cloud Foundry. https://github.com/mainephd/teradata-cloudfoundry

To run the application locally in the cloudfoundry docker container I ran the below steps.

  1. cf push the above application to cloud foundry.
  2. Download the the tar of the application from cloud foundry using the download droplet cf plugin.
  3. Extract the tar download from step 2 to a directory.
  4. Start the cloud foundry docker container docker run -ti cloudfoundry/cflinuxfs2 bash
  5. In another terminal run docker ps and not the name of the container id of the image started in step 4.
  6. In same terminal you used in step 5 run docker cp extractedapptardirectory/ [containerid]:/app
  7. Back in the terminal started in step cd /app you should now see the contents of the application along with the python run times in the .heroku directory and the vendored teradata libraries in the vendored/ directory.
rijumathew-teradata commented 7 years ago

@mainephd Hi! How did the application at "https://github.com/mainephd/teradata-cloudfoundry" attain its current form? Did someone install the TTU software and get that created? We were able to cf push the application onto Cloud Foundry, and perform the remaining steps. However, it would be interesting to know how the application at "https://github.com/mainephd/teradata-cloudfoundry" was created in the first place.

mainephd commented 7 years ago

I installed TTU software using the cloudfoundry/cflinuxfs2 docker image and included them when i pushed the application. @rijumathew-teradata

How were you able to perform the remaining steps? Did you deploy to Pivotal Web Services or pcfdev?

To be clear the docker image cloudfoundry/cflinuxfs2 has less restrictions on what can be done versus the droplet form it takes when it is executing on Cloud Foundry.

rijumathew-teradata commented 7 years ago

Yes @mainephd. We used Pivotal Web Services for the deployment.

If it is not too much to ask for, could you please let us know the steps you took when you "installed TTU software using the cloudfoundry/cflinuxfs2 docker image"? I think that is the piece we are missing, and wish to make sure we understand well. Thanks a lot for your time!

Regards, -Riju

andrewtmendoza commented 7 years ago

@escheie - do you know whether this module works with LDAP? I've gotten it to work with TD2, but am receiving an error when I try to change the LOGMECH:

import teradata
udaExec = teradata.UdaExec(appName="test", version="1.0",logConsole=False,configureLogging=False)
conn = udaExec.connect(method="odbc", system="TDPROD", username="user", password="xxx", LOGMECH="LDAP")
#error happens here

The error is:

DatabaseError: [28000] [Teradata][ODBC Teradata Driver][Teradata Database] The UserId, Password or Account is invalid. , [Teradata][ODBC Teradata Driver]

I'm also wondering whether the issue could be with a symbol in my password, since it contains a "+" character.

Thanks, Andrew

escheie commented 7 years ago

@andrewtmendoza - Use authentication="LDAP" instead of LOGMECH="LDAP".

mainephd commented 7 years ago

@rijumathew-teradata I have updated the readme with instructions on how I installed the TTU drivers. Github Repo Let me know if you need any more information.

wdutcher commented 7 years ago

@escheie - Did the TTU team provide a response on the request to change the the process that verifies the ownership of the .genuine_TTU file?

@mainephd - Did you find a work-around for the root ownership requirement on .genuine_TTU?

Thanks, William

escheie commented 7 years ago

@wdutcher - The response was that they would like to drop this requirement that .genuine_TTU be owned by root, however the change has not been committed to a specific release yet.

TheKing66 commented 5 years ago

ODBC environment variables were incorrectly set, after setting them correctly. Issue fixed.

Can you specify the variable changes fixed the problem ?

rayappagari commented 4 years ago

I set env variables as: export ODBCINI=/opt/teradata/client/ODBC_64/odbc.ini export ODBCINST=/opt/teradata/client/ODBC_64/odbcinst.ini export LD_LIBRARY_PATH=/opt/teradata/client/ODBC_64/lib

My Python program failing trying to connect to Teradata:

File "/home/hadoop/.local/lib/python2.7/site-packages/teradata/tdodbc.py", line 454, in init checkStatus(rc, hDbc=self.hDbc, method="SQLDriverConnectW") File "/home/hadoop/.local/lib/python2.7/site-packages/teradata/tdodbc.py", line 231, in checkStatus raise DatabaseError(i[2], u"[{}] {}".format(i[0], msg), i[0]) teradata.api.DatabaseError: (0, u'[IM002] [DataDirect][ODBC lib] Data source name not found and no default driver specified')