Hi, I’m very new to ignition and I’m having issues indexing data from a SQL query. The code below queries a single line from a database then I want this data to be in a list of lists that can be further operated on.
for i in range(3): #Gets the name, min, max and units for the appropriate parameter name and number
SQL_statement =("SELECT fldDescription FROM %s WHERE tblControlModeParameters.fldID=%d"\
"ORDER BY tblControlModeParameters.fldPrmtrNmbr;")%(ctrlPrmtrTbl,control_mode[i])
temp = system.db.runQuery(SQL_statement,DBNAME)
for a in range(9):
mode_prmtr_desc[i][a]=temp[a][0]
DBNAME, ctrlPrmtrTbl and control_mode are all predefined.
If I try and run this as part of a larger script I get an error stating “row index 0 out of range”. this error relates to the temp dataset being indexed (I’ve tested this with different values instead of a). the odd thing is that if I copy the same section of code to the script console it works perfectly!
in essence my question is:
why am I getting this error despite it working in the script console?
how is an SQL dataset formatted and am I going about using this dataset incorrectly?
thanks in advance, let me know if I’ve not made anything clear.