Tag read scripting help

Can someone please tell me why this code is having trouble with the declared variable LimVal?
Are we not correctly referencing the variable after LIMIT?

LimVal = system.tag.read(“LINE 1/Tag_BO3_28_0-28_15_Int”).value
query=“SELECT L1_SECA_ITEM FROM L1_DRYER_TRACK ORDER BY t_stamp desc LIMIT (LimVal)”
table1 = system.db.runQuery(query,“PM_DATA”)

Thanks

You need to use Python string substitution to get the variable added to the query string:

LimVal = system.tag.read("LINE 1/Tag_BO3_28_0-28_15_Int").value query="SELECT L1_SECA_ITEM FROM L1_DRYER_TRACK ORDER BY t_stamp desc LIMIT %s" % (LimVal)

The syntax is just a little off:LimVal = system.tag.read("LINE 1/Tag_BO3_28_0-28_15_Int").value query="SELECT L1_SECA_ITEM FROM L1_DRYER_TRACK ORDER BY t_stamp desc LIMIT %d" % LimVal table1 = system.db.runQuery(query,"PM_DATA")

Thank you, James and Travis. That worked beautifully!