# S7-1200 to MariaDB

**URL:** <https://discourse.nodered.org/t/s7-1200-to-mariadb/79424>\
**Category:** Industrial\
**Created:** [27 June 2023 01:23 UTC](https://discourse.nodered.org/t/s7-1200-to-mariadb/79424 "2023-06-27T01:23:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexmacabu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alexmacabu/32/27328_2.png) [@alexmacabu](https://discourse.nodered.org/u/alexmacabu)\
**Post date:** [27 June 2023 01:23 UTC](https://discourse.nodered.org/t/s7-1200-to-mariadb/79424/1 "2023-06-27T01:23:18Z")

</div>

Hello there! I am using **node-red-contrib-s7** v.3.1 and **node-red-node-mysql** v.1.0.3 to read data from a PLC and perform a INSERT on a MARIADB Database. Right now I can both read from the PLC and perform INSERT on the DB using separately but when I try put those two together I struggle with the syntax.

FYI the datatype or the variable is REAL and I have a 'S7 Input' Node feeding a 'Function' node

```auto

var LeftSide_Dist = msg.payload;

LeftSide_Dist = LeftSide_Dist.toString();
var topic = "INSERT INTO myDB.stack (LeftSide_Dist, RightSide_Dist, LeftSide_Shift, RightSide_Shift, Top_Angle, Bottom_Angle, Code, `timestamp`) VALUES("+"LeftSide_Dist"+", 2, 3, 4, 5, 6, 7, current_timestamp())";

msg.topic = topic; 
return msg;

```

Can someone help me out?

---

<div class="post-metadata">

**Author:** ![alexmacabu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alexmacabu/32/27328_2.png) [@alexmacabu](https://discourse.nodered.org/u/alexmacabu)\
**Post date:** [27 June 2023 01:53 UTC](https://discourse.nodered.org/t/s7-1200-to-mariadb/79424/2 "2023-06-27T01:53:34Z")

</div>

Yay, I got the syntax right! I just had to lose the double quotes because it was a variable, kinda obvious...

```auto
var LeftSide_Dist = msg.payload;

LeftSide_Dist = LeftSide_Dist.toString();

var topic = "INSERT INTO myDB.stack (LeftSide_Dist, RightSide_Dist, LeftSide_Shift, RightSide_Shift, Top_Angle, Bottom_Angle, LensCode, `timestamp`) VALUES("+LeftSide_Dist+", 2, 3, 4, 5, 6, 7, current_timestamp())";

msg.topic = topic;

return msg;

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 July 2023 01:53 UTC](https://discourse.nodered.org/t/s7-1200-to-mariadb/79424/3 "2023-07-11T01:53:39Z")

</div>

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