Help with looping through sqlite result

Using kodular’s built in sqlite extension I am able to create tables and insert data into my table but how do I read and loop through the results?

This is my sql to create the table: CREATE TABLE IF NOT EXISTS meters ( meterid TEXT NOT NULL, metername TEXT NOT NULL, email TEXT, lat REAL, long REAL, startmonth INT, startday INT, updatedat TEXT, CONSTRAINT idemail UNIQUE (meterid));

To insert the data i ran this one a few times, changing values.

I can display all the results as shown in the first 2 blocks below, but if i try to get a specific value (3rd and 4th block) I get this error: The operation select list item cannot accept the arguments: , [meterid,metername,email,lat,long,startmonth,startday,updatedat], [1]

blocks (2)

You are using label inside the for each item list, if so the label will show the last value of the item in the list… If you use add items to the list to any local or global variable and set the label to show text of that variable, then you will see the whole result

Thanks for the response. I am aware of that. I am simply trying to at least display 1 value for now, but even that does not work because the select list item responds with this error:

The operation select list item cannot accept the arguments: , [meterid,metername,email,lat,long,startmonth,startday,updatedat], [1]

I am assuming that the row result is not a list, but also a dictionary result does not seem to work.

The reason is, global metres is not acceptor consider as list by the app. Since you are getting the result as CSV format in global meters, just add
list from CSV row text to list (get global metres ) in the place of for each row in the list and try. You will see the last item of the result

Got that?

Thank you. The csv to list worked, even though it wasn’t specifically related to a global variable as you can see here:

I am getting another error now though. The headers are always returned, even though i set Returnheader to false.

I believe this is a bug. See SQLite returns unwanted column header - #8 by Taifun

Maybe instead of using for each item in list use for each number from 2 to lenght of list by 1

1 Like

It’s a longtime bug I see. I’ll start looping from column 2 then. Thank you.

1 Like

i think use timer