All Forums Aster
rp186020 1 post Joined 06/12
18 Dec 2012
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")
);

 

JeffHaber 12 posts Joined 11/13
10 Dec 2013

“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.

You must sign in to leave a comment.