I have an update query that is scheduled to run every day at 5am. It's purpose is to prune data from an SQL Express Database. It's done daily so that the load for the query is more reasonable. It seems like it's running, but not deleting the rows. Eventually, it gets to the point where the query times out, and that time out error pops up in the log. Nothing else in the logs. If I run the same script from a button on the screen it runs without an error popup. When I run the same DELETE query in SSMS it works as expected.
#get the most recent date in the table
date = system.db.runQuery("SELECT TOP 1 t_stamp FROM Data ORDER BY t_stamp DESC")[0][0]
#calculate the pruning date for Data table and Chem table
dataPruneDate = system.date.format(system.date.addMonths(date, -3), "yyyy-MM-dd")
#create query stings for Data table and Chem table
dataQueryString = str("DELETE Data WHERE t_stamp < '" + dataPruneDate + "'")
#run query for Data table and Chem table
system.db.runUpdateQuery(dataQueryString)
The log error shows some extra parameters for runQuery()
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 15, in onScheduledEvent at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:392) at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runUpdateQuery(AbstractDBUtilities.java:188) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.Exception: java.lang.Exception: Error executing system.db.runUpdateQuery(DELETE Data WHERE t_stamp < '2022-10-11', AppDataLog, , false)