Help: Stream SQL-MR using Python.

Aster
Teradata Employee

Help: Stream SQL-MR using Python.

Hi,

I'm a Python dev for the past couple of years and connecting to PostgreSQL using the psycopg2 module.

Now, I'm using Teradata Aster, as my training, I tried creating a simple sql-mr function using a python. Given the table, the sql-mr will populate the tables with random values.

What do I need to connect to a Aster Database?

I see a lot of Java code that do this but I can't seem to find a Python version of this.

Other SQL-MR Example using Python would be a great help!

Thanks!

Basically my code will be like this:

Pseudocode:

import jdbc, sys

conn = Connect(AsterDatabase, Username, Password, Host, Port)
cur = conn.cursor()

cur = getTableColumnsAndDatatype()

records = generateRecords()

for record in records:
cur.execute("INSERT INTO table(....)VALUES(record)")

print "done"
sys.stdout.flush()

SELECT *
FROM STREAM(
ON table
SCRIPT("python filename.py")
OUTPUTS("result varchar")
);
Tags (3)
1 REPLY
Teradata Employee

Re: Help: Stream SQL-MR using Python.

“SQL-MapReduce and Stream API for Python, Perl, and Other Types of Scripts” section of the “Teradata Aster Big Analytics Appliance DatabaseUser Guide” contains example of a python script which could be invoked in Aster Stream query to generate a small sample table.