Unable to bulk update Google Sheet with SQL Query

Hi, I am having what may end up being a simple issue, but I am trying to put my raw array data from an SQL Query into a Google Sheet through Bulk Update. Currently I am still a bit confused on how Primary Key Column and Array of rows to update works after searching for awhile. I have tried running Javascript which creates a variable newArray and maps the query to it which then returns the newArray.

let newArray = Phoenix.map;
return newArray;

To not have this run on too long, I was wondering if there was a simple way to put my data from an SQL Query straight into Google Sheets with each column in the Query being a separate column.

Also still new to using retool so I may have missed something obvious.

After additional testing, would using update a spreadsheet work better to insert data?

Still looking for an answer on this, I have tried many different approaches so I was wondering if I was missing an easy one.

Hi @Luke_Perez, welcome to the community :wave:

If you have a spreadsheet that has the same column names as the ones in your query, you can directly use the bulk update assuming you have an array of object as a result of your SQL query. Treat the Primary Key Column similar to how SQL is connecting tables using the ON statement.

It would also be helpful if you can provide a sample data that you've been playing around (of course remove any PII or sensitive info).

That actually helps a good bit thank you, but fortunately I fixed my problem earlier today! I was trying to effectively put all my data from the SQL Query into a blank google spreadsheet, and ended up doing this:

let data = formatDataAsObject(query.data);
return formatDataAsArray(data);

I don't fully understand how it fixed it but it did :sweat_smile:

That's a confusing fix but glad it worked on your end. :smiley: