Postgres Insert

I’m trying to get a simple insert statement for postgres to work, and get an error. What am I doing wrong here?

Hi @glen1

First off, welcome to the Pipedream community. Happy to have you!

Thanks for sharing the screenshot, much easier to follow along. I noticed in the Inputs tab that there is actually one computed string, instead of two.

When you open the Values prop dropdown, did you enter in a custom expression that defines one row?

I entered only what you see there. What should the values look like?

Hi @glen1

I believe the issue is that you may have entered in both values in the same row.

Please try opening the Values prop and see if there is only one row, and then you can use the plus icon to add another row and move your second entry to it:

yes, there’s only one row because I’m trying to pass in all of the columns for that row as a set of values. So, insert into the table using VALUES(xx,xx) which works in SQL form. Can I do that here?

Hi @glen1

That’s correct, this action inserts one single row.

However, the Values property is an array of values. If you pass two strings to one value entry, only one value is defined.

Your query is expecting two values.

So either you can use the plus icon to and define the second value, as shown in the screenshot below:

Or alternatively use the Enter a custom expression option and make sure to wrap your expression in parantheses to make sure it’s treated as an array and not a single value:

ahh… Thanks. I’m not getting that choice to pick out an individual value. It’s just showing as a string. I tried different tests, but can’t seem to figure it out. What exactly does the body need to look like so that the values can be parsed?

Make sure you click the select path option when hovering over data in the dropdown.

Here’s a short video from our University series to show you how to use the step exports explorer:

yes, I did. Take a look here and you’ll see that it’s one line:

Thanks for the screenshot, that’s very helpful @glen1 .

The body itself needs to be parsed into a Javascript object from the JSON string.

I recommend adding a Node.js code step in between the trigger and the Postgres step, simply to parse the JSON from the steps.trigger.event.body string.

go it ok. The call is originating at my code, so I can change it. Just wondering if there was a better format to send it in… I guess JSON, without stringify is the answer…

thanks for all of your help

1 Like