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.

Re: Teradata Python Module

Eric:

I did have $ in my password, so when i corrected my connect statement:

session = udaExec.connect (method="odbc", system="tdprdcop1", username="uname", password="pass$$2015")

my code ran successfully

but when in tried to execute this statement:

session =udaExec.connect("${dataSourceName}")

it ERROR'ed out with same error as before:

here is my .ini file

# Application Configuration

[CONFIG]

appName=searchTeradata

version=1

logConsole=False

logLevel=INFO

dataSourceName=TDPROD

# Default Data Source Configuration

[DEFAULT]

method=odbc

charset=UTF8

# Data Source Definition

[TDPROD]

system=tdprdcop1

username=uname

password=pass$$2015

Teradata Employee

Re: Teradata Python Module

@pwspann - I will investigate a fix but in the meantime escaping it twice when its in the config file (e.g. "$$$$") should work.

Teradata Employee

Re: Teradata Python Module

@pwspann - A new version of the module has been released that fixes the escape issue you encountered.   

The 15.10.00.09 version also includes a couple other fixes/enhancements.

Enthusiast

Re: Teradata Python Module

Hello,

could some one share an example using the REST API instaed of the ODBC.

Teradata Employee

Re: Teradata Python Module

@sunnysteve - Here is how the connect method should look in the Hello World example if using REST:

session = udaExec.connect(method="rest", host="resthost.example.com", system="tdprod", username="xxx", password="xxx");

The method should be set to "rest".  The host parameter should be the hostname of the system hosting the REST service.  The system name should be the alias of the Teradata System configured in the REST service.   The username and password should be the same username and password that you would use with ODBC to connect to the Teradata System.

Enthusiast

Re: Teradata Python Module

Hello

i have problem with type date from teradata, i have decimal(3,1) and

when i import by python the value are NA,

then i see MydataTypeConverter() but i don't know how i do the function,

please help

thanks

Teradata Employee

Re: Teradata Python Module

@rlobera - Could you clarify the issue you are having with a simple example?

Teradata Employee

Re: Teradata Python Module

Hello

I am inserting big string (len(tdch_log)=47821) into teradata table with "tdch_log CLOB (10M) UNICODE" column via:

session.execute("""UPDATE FEED_CONTROL SET end_timestamp=?, tdch_code=?, tdch_records=?, tdch_log=? WHERE load_id=? AND table_id=?""",(end_time,tdch_error_code,tdch_imported_records,tdch_log,loadId,row.table_id))

And have the next error...

------------------------------------------------------------------------

Traceback (most recent call last):

  File "./TDCH_Rest_Archive2.py", line 178, in <module>

    (end_time,TDCH_error_code,TDCH_imported_records,TDCH_log,loadId,row.table_id))

  File "/usr/local/lib/python2.7/site-packages/teradata/udaexec.py", line 640, in execute

    self.internalCursor.execute(query, params, **kwargs)

  File "/usr/local/lib/python2.7/site-packages/teradata/udaexec.py", line 701, in execute

    self._execute(self.cursor.execute, query, params, **kwargs)

  File "/usr/local/lib/python2.7/site-packages/teradata/udaexec.py", line 766, in _execute

    raise e

teradata.api.DatabaseError: (3798, u'A column or character expression is larger than the max size.')

--------------------------------------------------------------------------

Is there special method or workaround how to insert into CLOB?

Enthusiast

Re: Teradata Python Module

SELECT top 5 NUM_CELULAR,RED,cuociente_celulares_et, celulares_e
 FROM ubd01.score_cluster_claro where red='M'

NUM_CELULAR RED cuociente_celulares_et celulares_e
58560599 M 0,6 0,5
74600079 M 1,0 0,1
53858484 M 1,0 0,8
91615986 M 1,0 0,1
85394366 M 1,0 0,3

Python:
session.close()
import teradata
 
udaExec = teradata.UdaExec ()
 
with udaExec.connect("${dataSourceName}") as session:
    for row in session.execute("SELECT top 5 NUM_CELULAR,RED,cuociente_celulares_et, celulares_e \
                               FROM ubd01.score_cluster_claro where red='M'"):
        print(row)

and the result in Python is:

Row 1: [58560599, M, NaN, NaN]
Row 2: [74600079, M, NaN, NaN]
Row 3: [53858484, M, NaN, NaN]
Row 4: [91615986, M, NaN, NaN]
Row 5: [85394366, M, NaN, NaN]

I have the query in teradata, above, and the result in teradata is:

Teradata Employee

Re: Teradata Python Module

@alpanchino - I am unable to reproduce the error you are experiencing and can successfully insert and update clob values of multiple MBs using the python module.   Can you first make sure you are using the latest version of the python module?  If that doesn't fix it can you change your example to only work with the CLOB column and see if you can still reproduce the error?