Teradata Python Module

Tools
Tools covers the tools and utilities you use to work with Teradata and its supporting ecosystem. You'll find information on everything from the Teradata Eclipse plug-in to load/extract tools.
Enthusiast

Re: Teradata Python Module

To avoid crossposting I would like to to post just the link to the full question here http://community.teradata.com/t5/Tools/Introducing-Teradata-Wallet/m-p/68738/highlight/true#M3585

But because it happens when calling tdwallet from Teradata Python Module I would like to get your attention. The question is this:

 

When calling tdwallet from a Teradata Python module it fails if the user name is stored in tdwallet. If only the password (string "database_pw") is retrieved from the tdwallet the login completes fine. What is the correct way of using tdwallet here or is it a bug?

 here are the relevant strings from the python script

import teradata
session = udaExec.connect(method="odbc", system="my.td.url.com"
, username="$$tdwallet(user)", password="$$tdwallet(database_pw)")

 

Enthusiast

Re: Teradata Python Module

Does this work for anybody at all? Could you please just let me know here?

, username="$$tdwallet(user)", password="$$tdwallet(database_pw)")
JP
Visitor

Re: Teradata Python Module

Hi Eric,

 

I got teradata module installed.  However I'm not able to import the module. I'm getting the following errors:

>>> import teradata
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/application/dwh/pythonve/lib/python3.4/site-packages/teradata-15.10.0.20-py3.4.egg/teradata/__init__.py", line 22, in <module>
    from .udaexec import UdaExec, UdaExecCheckpointManager  # noqa
  File "/application/dwh/pythonve/lib/python3.4/site-packages/teradata-15.10.0.20-py3.4.egg/teradata/udaexec.py", line 41, in <module>
    from . import tdrest  # @UnresolvedImport
  File "/application/dwh/pythonve/lib/python3.4/site-packages/teradata-15.10.0.20-py3.4.egg/teradata/tdrest.py", line 29, in <module>
    import ssl
  File "/xenv/python/X/3.4.1l_64_RH5/lib/python3.4/ssl.py", line 97, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: No module named '_ssl'

 

Since our server does not have internet access we cannot do pip online installation. I downloaded the package from pypi and did the installation by "setup.py install", please find below the last 3 lines of the output :

 

Installed /application/dwh/pythonve/lib/python3.4/site-packages/teradata-15.10.0.20-py3.4.egg
Processing dependencies for teradata==15.10.0.20
Finished processing dependencies for teradata==15.10.0.20

 

You suggested earlier to build  it with SSL support to fix the issue.  May I know how to get the openssl header files installed and how to enable SSL support when I do it with "setup.py teradata" ?

 

 

 

Highlighted
Enthusiast

Re: Teradata Python Module

Hello, i have a question about custom query banding. 

 

in the documentation, there's a one-liner saying:

 

Additional custom Query Bands can be set by passing a map (dict) as the queryBand argument to UdaExec.connect().

I tried doing that:

 

RUN_NME = "V_2_O"
STEP_NME = "MERGE_ODS_VKX0500T"

queryBandMap =  {"RunName":RUN_NME,"StepName":STEP_NME}

 

 

 

with udaExec.connect("${dataSourceName}",queryBand=queryBandMap) as session: 

 

 

and it runs but with no changes to the query band.  I looked through the function definition for UdaExec.connect() and it references queryBands as an argument refere3nce, but I have tried that with no results. Can someone provide an example of passing a custom query band to udaexec.connect?

Enthusiast

Re: Teradata Python Module

Thank you for the details. Can we use this module to run only teradata sql? can we use this module to run other teradata utilities like fastload, mload, etc? 

 

-Suhail

Teradata Employee

Re: Teradata Python Module

Hi,

 

Thanks for the article.

 

I am trying to use the code from the example one and two:

Example 1

======================

 

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

Example 2

==================

import teradata
udaExec = teradata.UdaExec ()
with udaExec.connect("${dataSourceName}") as session: 
for row in session.execute("SELECT * FROM ${table}"):
print(row)

 

But I am getting the below error on both code samples:

 

C:\Python27\Scripts>hellotd.py
Traceback (most recent call last):
  File "C:\Python27\Scripts\HelloTd.py", line 7, in <module>
    username=" ", password=" ");
  File "C:\Python27\lib\site-packages\teradata\udaexec.py", line 183, in connect
 
    **args))
  File "C:\Python27\lib\site-packages\teradata\tdodbc.py", line 428, in __init__
 
    SQL_NTS, None, 0, None, 0)
WindowsError: exception: access violation reading 0x00000000
Exception ValueError: 'list.remove(x): x not in list' in <bound method OdbcConne
ction.__del__ of OdbcConnection(sessionno=0)> ignored