How do you fill a ListView with fields contents from SQLite

Hi All,

I am using TIMA2 SQLite extension and all is working well. Now I need to do this:

I have this select: SElECt obras, cidade FROM obras which returns two records. Then it generate a list with the contents of the fields. My goal is to fill a ListView, but inserting headers, like this:


Obra: 001-obra-1
Cidade: New York

Obra: 001-obra-2
Cidade: Miami

ANy ideas? I'm stuck with this...

TIA,

Please show the raw output from the query

See

1 Like

Thank you for the example, but this is not the case. What I need to know is how to receive data from a SELECT * FROM table from SQLite in order to fill a ListView.

Where is the cidade data ?

You appear to know how to retrieve the data from a select query, @ABG's YAML example shows how to present the data in the format that you requested....

1 Like
Do It Result: [[[obra, 1.1.22 COROADOS], [cliente, CONSDON ENGENHARIA E COMERCIO LTDA]], [[obra, 4.3.22 BURITIZAL], [cliente, NEOCOGEC]]]

CIDADE was just an example. The real field is CLIENTE. As you can see, there are two records and I am using ReturnColumnHeaders as TRUE.

So you want data to be presented in this format:

1.1.22 COROADOS
CONSDON ENGENHARIA E COMERCIO LTDA
__________________________________________

4.3.22 BURITIZAL
NEOCOGEC
__________________________________________

1 Like

Yes, almost this. What I want to put in the listview is:

Obra - 1.1.22 COROADOS
Cliente - CONSDON ENGENHARIA E COMERCIO LTDA
__________________________________________

Obra - 4.3.22 BURITIZAL
Cliente - NEOCOGEC
__________________________________________

Got it.

Your download format is three dimensional, not fitting the usual table or dictionary patterns.

You might get it by coercing the lists of key,value pairs into dictionaries.

Some coding needed here.

1 Like

Maybe this will work.

Draggable.

1 Like

The text you supplied is not parseable as JSON, because it lacks quotes.

It needs work upstream.

1 Like

It can be handled with list blocks, as Sunny has shown....but the issue is there are no quotes around the strings....

Works if list is of this format.

If I remember correctly, sql queries return data in csv table format but this one is not.

1 Like

I have just come to my senses.

You may need to use the listfixer block (as shown in the documentation...)

This should return a workable json array format

1 Like

@vknow360 thank you for your suggestion... I'll try here and tell you my results.

@TIMAI2 thank you for point this... I am already using this block. Starting tests right now.

Guys, I'm almost there. Let me explain the situation now:

When I use SELECT obra, cliente FROM obras using the ListFixer block, my result is:

[["1.1.22 COROADOS", "CONSDON ENGENHARIA E COMERCIO LTDA"], ["4.3.22 BURITIZAL", "NEOCOGEC"]]

So, in this case, I have two records. But imagine the result could be four or five or more records. In this case how do I use the procedure explained by @vknow360 to make a join with string "Obra: " and "1.1.22 COROADOS" and "Cliente: " and "CONSDON ENGENHARIA E COMERCIO LTDA", once these strings ("Obra" and "Cliente") are not from the query result?

Use this procedure from my prior post:
image

It needs row 1 to contain the headers, though.

You can customize from here.

1 Like

Are you not returning column headers ?