How to use mustache template in inserting array into sql table

Hello, im a newbie here. I am reading the documentation here mustache(5) - Logic-less templates.
but it is not clear how to insert an array data into my sql table. I want to input my array data (image 1) into an sql table with columns name, codename. When i do it in a template node(image2) , i got an error message of syntax error. this is the output of the msg.query of the template node(image3). and the error is because of the syntax, the comma at the last vallue of the array. How can it be fixed? Any help will be much appreciated :slight_smile:


As much as I would like to be a database person.....

Why can't you delete the last ,?

You should paste the code/s rather than screen-shot'ing the pictures.
It would help and make it a lot easier for people to help you.

Hello, the image with last , is the result of the msg.query from the template node so I cannot edit that.
Sorry i cannot pastes code/s.

You can post code/s.

You just have to learn how to.

The </> button is used to allow you to paste code.

Exporting from your end is done with the EXPORT of the MENU of Node-Red (Top right corner - burger bar icon.)

Copying/pasting debug is done from the small clipboard icon to the right of the message in the debug window.

Sorry i mean i cannot pastes my codes as it is confidential. I want to ask more on a general ways of doing thing in nodered.

You should be able to cut down to nodes that do the basics of what you want to do.

Then post that as a base-line.

Then people can see (better) what you want to do and help you quicker.

You then get their answer and tweak them to your needs.

the {{#payload}} should be on the top most before the INSERT INTO and the
{{/payload}} should be on the bottom after the ON CONFLICT statement.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.