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

Anyone knows how to retrieve multiple result sets from ODBC? e.g.

How to retrieve both table and view DDLs from "show select * from dbc.dbcinfo". I tried nextset() but it didn't seem to work. Suggestions? Thanks.

udaExec = teradata.UdaExec(appConfigFile='udaexec.ini')

    with udaExec.connect("${dataSourceName}").cursor() as c:

            c.execute("select * from dbc.DBCInfo")

            #c.execute("show view dbc.DBCInfo")

            while 1==1 :

                rows = c.fetchall()

                #print "# of rows returned : {0}".format(len(rows))

                for row in rows :

                    for line in re.split("\r\n|\n\r|\n|\r", row[0]):

                        print(line)

                if c.nextset() is None:

                    break

Enthusiast

Re: Teradata Python Module

The above code should be:

c.execute("show select * from dbc.DBCInfo")

Teradata Employee

Re: Teradata Python Module

@seabull - Your example works for me.  Please try upgrading your Teradata Python Module to the latest version as I belive there was a bug that has since been fixed that may be causing the issue you are hitting.

Enthusiast

Re: Teradata Python Module

@ericscheie, Thanks! It works after upgrading from 15.10.0.6 to 15.10.0.7

Teradata Employee

Re: Teradata Python Module

Absolutely amazing utility - seriously impressive. thank you

One question, is it possible to deploy an extenal (c-code) UDF using the module?

I ask because this involves deploying a SQL script (e.g. below) which references a separate file (in this case, isdate1.c) containing the external function.

Is this currently possible using the module?

REPLACE FUNCTION SYSLIB.isdate (
InputDate VARCHAR(29) CHARACTER SET LATIN,
DateFormat VARCHAR(29) CHARACTER SET LATIN,
SeparatorChar VARCHAR(1) CHARACTER SET LATIN,
CenturyBreak INTEGER,
FailModeFlag INTEGER
)
RETURNS DATE
LANGUAGE C
SPECIFIC isdate1
NO SQL
DETERMINISTIC
PARAMETER STYLE SQL
CALLED ON NULL INPUT
EXTERNAL NAME 'CS!isdate1!isdate1.c'
Teradata Employee

Re: Teradata Python Module

@eo186005 - Unfortunately no, the connectivity methods supported by the Python module (ODBC and REST) do not support deploying external UDF code at this time.  I've opened feature requests to enable this functionality so that it can be included in the future.   Thanks.

Enthusiast

Re: Teradata Python Module

Hi Eric,

I am unable to get this installed. I am getting the error

[root@ttudev teradata-15.10.0.7]# ./setup.py install

The teradata module does not support this version of Python, the version must be 2.7 or later.

I have versions 2.6 and 3.4 installed.  I made python3.4 the default one by running alias python=python3.4. However it's still not taking it. How can I fix this?

Teradata Employee

Re: Teradata Python Module

@Roopalini - Give one of the following a try:

python3.4 setup.py install

or

python3.4 -m pip install teradata

Enthusiast

Re: Teradata Python Module

Eric - Still no luck :-(. I tried both.

[root@ttudev teradata-15.10.0.7]# python3.4 -m /usr/bin/pip install teradata

/usr/local/bin/python3.4: No module named /usr/bin/pip

[root@ttudev teradata-15.10.0.7]# python3.4 ./setup.py install

Traceback (most recent call last):

  File "./setup.py", line 24, in <module>

    from setuptools import setup

ImportError: No module named 'setuptools'

Enthusiast

Re: Teradata Python Module

Tried this way too. same error.

[root@ttudev teradata-15.10.0.7]# python3.4 setup.py install

Traceback (most recent call last):

  File "setup.py", line 24, in <module>

    from setuptools import setup

ImportError: No module named 'setuptools'