How does retool store data returned form SQL?

Hi Team

Can someone suggest a data format for SQL results?

My goal is to store data in the format below when data is returned from a SQL query. Section and Label are column names.
[
{ section: "Orders", label: "New Order" },
{ section: "Orders", label: "Order List" }
]

1 Like

HI there @rtulachan, and welcome to the forum!

Are you asking about the best column format type to store data in a json format like the one you provided?

If so, my go-to is a jsonb column, which then will return the results as an array whenever you make a get query including that column.

Apologies in advance if I misunderstood the question.

Welcome to the community, @rtulachan! I think I understand what you're asking, but please correct me if I'm off base. By default, Retool returns the results of most SQL queries as an object where each key is the column and the associated value is an array of individual records.

This isn't always the most intuitive, but you can easily tell Retool to reformat it using the query's built-in transformer and the formatDataAsArray function.

The query now returns an array of objects, like you're describing. I hope that helps!

1 Like