@open-kappa/node-red-contrib-mydb
Judging by the number of people who download this, I'm certain I'm just missing something basic in my attempt to use it.
I have a simple postgres database and table set up.
I have 5 columns.
AccessToken: (TEXT)
SecondsPassed: (SMALLINT)
RoomOccupied: (BOOLEAN)
RoomLightsOn: (BOOLEAN)
RoomAVSystemActive: (BOOLEAN)
When I try a simple insert command where I: manually assign the values, it works without issue:
INSERT INTO "MYDATABASE"."test" ("SecondsPassed", "RoomOccupied")
VALUES (100, "TRUE");
The record shows up in the DB, and no errors, etc.
Now, I have a msg object that contains a payload:
msg.payload : Object
object
AccessToken: "1234ABCD5678EFGH"
SecondsPassed: 21
RoomOccupied: "FALSE"
RoomLightsOn: "FALSE"
RoomAVSystemActive: "TRUE"
When I try to use the data from the msg.payload object, I get errors.
The query looks like this:
INSERT INTO "MYDATABASE"."test" ("SecondsPassed", "RoomOccupied")
VALUES ({{msg.payload.SecondsPassed}}, {{msg.payload.RoomOccupied}});
The error states:
msg : error
"error: syntax error at or near ",""
Which is not exceptionally useful, but it does seem to relate to the comma that is separating the two values contained in the {{}}.
I have tried substituing a static value for each of the msg.payload objects above, ie:
INSERT INTO "MYDATABASE"."test" ("SecondsPassed", "RoomOccupied")
VALUES (100, {{msg.payload.RoomOccupied}});
and the error message changes to:
msg : error
"error: syntax error at or near ")""
or the other value:
INSERT INTO "MYDATABASE"."test" ("SecondsPassed", "RoomOccupied")
VALUES ({{msg.payload.SecondsPassed}}, TRUE);
and the error reverts back to:
msg : error
"error: syntax error at or near ",""
I'm at a loss. For my purposes, it seems this particular DB connector would work very well for the simple context I'm looking for, but for the life of me, I cannot get it to work unless I use static values.
Am I missing something with the {{}} syntax or something? I've tried single {} and triple {{{}}}, and while the error message may change, it never produces a positive result.
Would really appreciate any help.