Setting up Teradata Python Module on VMware image

Teradata Database on VMWare
Enthusiast

Setting up Teradata Python Module on VMware image

I was trying to run the Python module on my VMware instance, and ran into a stack of problems.

The python version on the VM instance (TDExpress15.10.0.7_Sles11_40GB_vp) was 2.6.9 which doesn't support the python module.  Trying to build a new Python 3 instance was missing readline.  Since the VM is SLES, with no repos, i kept hitting deadends.  Trying to use OSS repos kept screwing up my Gnome and making the VM image unusable.

Finally, I came up with these steps that worked, so I thought I would share

refererring to the Teradata Python Module(http://developer.teradata.com/tools/reference/teradata-python-module) reference for the final steps.

using a clean install of the 15.10 vm image, I did the following steps:

#set up a nameserver so we can reach the internet

cat << EOF > /etc/resolv.conf

nameserver 8.8.8.8

search td.teradata.com

EOF

#test connectivity

ping -c 5 www.google.com

#add an OpenSUSE repo to get Python3.  Trying to upgrade the 2.6.9 install was a failure

#accept repo access, and packages

zypper addrepo --refresh http://download.opensuse.org/distribution/13.1/repo/oss/ "OpenSUSE OSS 13.1"

zypper install python3

#install the python easyinstall in python3

cd /root

wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py

python3 ez_setup.py --insecure

#get and install the teradata python module

mkdir /root/terdata

cd /root/teradata


certificate

tar -xzvf teradata-15.10.0.17.tar.gz

cd teradata-15.10.0.17/

python3 setup.py install

#cp /opt/teradata/client/15.10/odbc_64/odbc.ini /root/.odbc.ini

#this is essentially the above file, with some values filled in

cat << EOF > /root/.odbc.ini

[ODBC]

InstallDir=/opt/teradata/client/15.10

Trace=0

TraceDll=/opt/teradata/client/15.10/lib64/odbctrac.so

TraceFile=/root/trace.log

TraceAutoStop=0

[ODBC Data Sources]

localdb_dsn=tdata.so

[localdb_dsn]

Driver=/opt/teradata/client/15.10/lib64/tdata.so

Description=Teradata database

DBCName=localhost

LastUser=

Username=dbc

Password=dbc

Database=dbc

DefaultDatabase=dbc

EOF

#append required ODBC entries to .bash_profile

cat << EOF >> /root/.bash_profile

export ODBCINI=/root/.odbc.ini

export ODBCINST=/opt/teradata/client/15.10/odbc_64/odbcinst.ini

export LD_LIBRARY_PATH=/opt/teradata/client/15.10/lib

EOF

#source them into the current environment

source /root/.bash_profile

#test the ODBC install

tdxodbc64 << EOF

localdb_dsn

dbc

dbc

select * from dbc.dbcinfo;

quit

EOF

#make someplace to create the HelloWorld.py

mkdir /root/python_td

cd /root/python_td


cat << EOF > /root/python_td/udaexec.ini

# Application Configuration

[CONFIG]

appName=HelloWorld

version=1

logConsole=False

dataSourceName=LOCAL_DB

table=DBC.DBCInfo 

# Default Data Source Configuration

[DEFAULT]

method=odbc

charset=UTF8

# Data Source Definition

[LOCAL_DB]

system=localhost

username=dbc

password=dbc

EOF


cat << EOF > /root/python_td/HelloWorld.py

import teradata

udaExec = teradata.UdaExec();

with udaExec.connect("\${dataSourceName}") as session: 

 for row in session.execute("SELECT GetQueryBand()"):

  print(row);

 for row in session.execute("SELECT * FROM \${table}"):

  print(row);

EOF

#and now the moment of truth

python3 HelloWorld.py

2 REPLIES
Enthusiast

Re: Setting up Teradata Python Module on VMware image

I decided I didn't like the Python version from the OSS package (3.3.2) since I wanted to use subprocess.run() so I went back to the install drawing board.

using the OSS repo, I found the right installs to get me readline, and then got and build Python 3.5

zypper install readline-devel

mkdir python

cd python


tar -xzvf Python-3.5.2.tgz

cd Python-3.5.2/

./configure --prefix=/usr/local

make install

i then removed my old python package, and so far, seem to be fine

zypper remove python3-base

zypper remove python3

Enthusiast

Re: Setting up Teradata Python Module on VMware image

Spoke too soon.  When I tried to install my teradata module in the new python install it yacked because I didn't have SSL support, so the setup couldn't figure out an https address.

I grabbed the OpenSSL devel lib

zypper install libopenssl-devel

then rebuild python.  that seemed to do the trick.  should have done that right when I got readline-devel in my above message.