Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Python Script - Syntax to define Variable


I have a python script and a Table iterator.
Can you please validate if the way variable is defined is correct ?

cursor = context.cursor()
cursor.execute('select count(*) from md_staging.${stage_table}')
result = cursor.fetchone()[0]
context.updateVariable('counter', str(result))

Table Iterator is based on a table having a column called stage_table. This holds stage table name.

In the Python script - I am setting a variable counter. It will hold the stage table count. And I am using a table iterator option to check counts of all the staging tables in a loop.

2 Community Answers

Matillion Agent  

Kalyan Arangam —

Hi Nachiket,

That looks fine to me. Do you not see the expected result?

You may check by printing the variable value -

print result


Nachiket Mehendale —

Hi Kalyan,

Yes, it is working. I have verified it. Thank you.

Post Your Community Answer

To add an answer please login