Teradata/PyTd

Dynamic Query

deezelmunky opened this issue · 0 comments

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)