0
votes

I'm experimenting with Tabpy in Tableau and writing data back to a database via a users selection in a dashboard. My data connections work fine. However, I'm having trouble passing a variable back into the SQL query and getting an error saying the "variable name" doesn't exist in the table that I'm trying to update. Here is my code. The error states that "dlr_status" does not exist on the table. This is the variable I'm trying to pass back to the query. The database is a postgre database. Any help is greatly appreciated. I've been researching this for several days and can't find anything.

SCRIPT_STR("
    import psycopg2
    import numpy as np
    from datetime import date
    
    con = psycopg2.connect(
     dbname='edw',
     host='serverinfo',
     port='5439',
     user='username',
     password='userpassword')
    dlr_no_change = _arg1[0]
    dlr_status = _arg2[0]
    update_trigger = _arg3[0]
    sql = '''update schema.table set status = dlr_status where dlr_no = dlr_no_change'''
    
    if update_trigger == True:
        cur = con.cursor()
        cur.execute(sql)
        cur.commit",
ATTR([Dlr No]), ATTR([dlr_status]), ATTR([Update_Now]))