Teradata / PyTd

A Python Module to make it easy to script powerful interactions with Teradata Database in a DevOps friendly way.
MIT License
108 stars 43 forks source link

Dynamic Query #118

Open deezelmunky opened 5 years ago

deezelmunky commented 5 years ago

I'm trying to write a program that modifies Teradata Table definitions to add Partitions as required. I would like to pull table and database names from a control table for starters and creating a show table SQL statement. My question is how can I feed the session.execute() function variables e.g. table and database names to export table definitions from Teradata. Here is what I have so far just to give a better idea:

with udaExec.connect("${dataSourceName}") as session: for row in session.execute("SELECT * FROM ${table}"): if row[2] == 'C': print('Table has been purged') elif row[2] == 'A': for definition in session.execute ("SHOW TABLE "{row[0]}"."{row[1]}";"): print(definition)