Writing a Json Message

Hey,
I am new to node red and have no experience with it. So my questions are: How can I write a JSON-Message and integrate it into an insert-statement? Furthermore, how can i transfer a Message into a Postgres Database?

image

Code:

[{"id":"43a7968a456ad836","type":"inject","z":"bba055f91ed61523","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"hello\":\"word\"}","payloadType":"json","x":350,"y":560,"wires":[["b1c5f77a335127f4"]]},{"id":"b1c5f77a335127f4","type":"postgresql","z":"bba055f91ed61523","name":"","query":"INSERT INTO table_name(column1)\nVALUES ('{{{payload.hello}}}');","postgreSQLConfig":"1e4da63817fa609c","split":false,"rowsPerMsg":1,"outputs":1,"x":570,"y":560,"wires":[["14946f51cb515194"]]},{"id":"14946f51cb515194","type":"debug","z":"bba055f91ed61523","name":"debug 77","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":770,"y":560,"wires":[]},{"id":"1e4da63817fa609c","type":"postgreSQLConfig","name":"","host":"localhost","hostFieldType":"str","port":"5432","portFieldType":"num","database":"postgres","databaseFieldType":"str","ssl":"true","sslFieldType":"bool","applicationName":"","applicationNameType":"str","max":"10","maxFieldType":"num","idle":"1000","idleFieldType":"num","connectionTimeout":"10000","connectionTimeoutFieldType":"num","user":"username","userFieldType":"str","password":"password","passwordFieldType":"str"}]

You need to install this node:
node-postgresql

exemple insert:

INSERT INTO table_name(column1)
VALUES ('{{{payload.hello}}}');

Thank you very much for your help.
When i try to deploy it, i get a "Error: certificate has expired" Message. Do you know how i can resolve it?

I don't understand at what node you received this message?

The Error occurs at the postresql node.

I see that you have specified SSL true in the server node config. I haven't used that node, but I wonder whether that is part of the problem. Did you intentionally set SSL?

Thank you. This was apparently the Problem. After setting the checkbox to False, the message didnt appear anymore.
It seems however that a new row is injected at my Database but without the message.


image
What have i done wrong?

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