This is my flow:
[
{
"id": "fadd60c5f197b58f",
"type": "function",
"z": "bc82c9919021ae85",
"name": "OK=0",
"func": "msg.topic = \"SELECT rowid, * FROM LocalData WHERE sent = \\\"0\\\" LIMIT 1\";\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 450,
"y": 200,
"wires": [
[
"9fa2a2d5ff688fce"
]
]
},
{
"id": "0ce7bbef78982ed1",
"type": "inject",
"z": "bc82c9919021ae85",
"name": "Every 5 sec.",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "5",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 280,
"y": 200,
"wires": [
[
"fadd60c5f197b58f"
]
]
},
{
"id": "a86c5cc835767ef4",
"type": "split",
"z": "bc82c9919021ae85",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 730,
"y": 200,
"wires": [
[
"83f1457149d09b4e"
]
]
},
{
"id": "83f1457149d09b4e",
"type": "function",
"z": "bc82c9919021ae85",
"name": "Write CloudDB",
"func": "msg.idLoc = msg.payload.rowid;\n\nmsg.topic = \"INSERT INTO Remote_data( date,time,product,timestamp) VALUES( \" +\n \"\\\"\" + msg.payload.datum + \"\\\", \" +\n \"\\\"\" + msg.payload.cas + \"\\\", \" +\n \"\\\"\" + msg.payload.produkt + \"\\\", \" +\n \"now()\" + \" );\";\n \n\nreturn msg;\n\n",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 880,
"y": 200,
"wires": [
[
"02ef89f19b973001"
]
]
},
{
"id": "8bb3d5fe03e3ddbe",
"type": "function",
"z": "bc82c9919021ae85",
"name": "OK=idCloud",
"func": "msg.idCloud = msg.parts.id\n\nmsg.topic = \"UPDATE LocalData SET sent = \\\"\" + msg.idCloud + \"\\\" WHERE rowid = \" + msg.idLoc + \";\"\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1230,
"y": 200,
"wires": [
[
"668c50affb2cfc29"
]
]
},
{
"id": "9fa2a2d5ff688fce",
"type": "sqlite",
"z": "bc82c9919021ae85",
"mydb": "3e46bfdc4b6df798",
"sqlquery": "msg.topic",
"sql": "",
"name": "LocDb",
"x": 580,
"y": 200,
"wires": [
[
"a86c5cc835767ef4"
]
]
},
{
"id": "668c50affb2cfc29",
"type": "sqlite",
"z": "bc82c9919021ae85",
"mydb": "3e46bfdc4b6df798",
"sqlquery": "msg.topic",
"sql": "",
"name": "LocDb",
"x": 1380,
"y": 200,
"wires": [
[]
]
},
{
"id": "02ef89f19b973001",
"type": "mysql",
"z": "bc82c9919021ae85",
"mydb": "070b3434d337b06e",
"name": "CloudDB",
"x": 1060,
"y": 200,
"wires": [
[
"8bb3d5fe03e3ddbe"
]
]
},
{
"id": "3e46bfdc4b6df798",
"type": "sqlitedb",
"db": "\\tmp\\bagy.db",
"mode": "RWC"
},
{
"id": "070b3434d337b06e",
"type": "MySQLdatabase",
"name": "SQL APP",
"host": "",
"port": "3306",
"db": "appdev_2",
"tz": "",
"charset": "UTF8"
}
]