# Two MQTT IN to SQLITE

**URL:** https://discourse.nodered.org/t/two-mqtt-in-to-sqlite/46880
**Category:** General
**Created:** [8 June 2021 22:58 UTC](https://discourse.nodered.org/t/two-mqtt-in-to-sqlite/46880 "2021-06-08T22:58:29Z")
**Posts on this page:** 5
**Page:** 2

<div class="post-metadata">

### Author: ![jjcfrank](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@jjcfrank](https://discourse.nodered.org/u/jjcfrank)
#### Post date: [9 June 2021 17:22 UTC](https://discourse.nodered.org/t/two-mqtt-in-to-sqlite/46880/21 "2021-06-09T17:22:27Z")

</div>

> [@zenofmud](#):
>
> When you changed the ownership to 777 you said anyone can access this file and so user 'pi' could so node-red can.

That makes sense! Good to know.

Sorry but an issue has just occurred. The code I have inside the function is this:

```auto
var sqliteTimeStamp = Math.round(Date.now() / 1000);
var temp = msg.payload["loungeSensor/temp"]; // << or whatever the copy path gives you
var humi = msg.payload["loungeSensor/humi"]; // << or whatever the copy path gives you

msg.topic = `INSERT INTO lounge_sensors (date, temperature, humidity) VALUES ('${sqliteTimeStamp}', '${temp}', '${humi}')`
return msg;

```

The problem is that when checking the table inside phpLiteAdmin I've noticed the readings are duplicated (see screenshot). I've also tested this putting 4 sensors with the same set up and I get in the table the readings duplicated X4.

Any thoughts?

![Screenshot 2021-06-09 at 18.10.23](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/9/19714c1b1dda09d952bb5d432260d56dce7d68fd.png)

EDIT:

Zenofmud, I can't make further posts due to reaching max of replies as a new user... so I have edited this reply. Here is the screenshot of my flow:

 ![Screenshot 2021-06-09 at 20.17.36](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/e/4e543de8e72cba40e60319168ac78c43495f3e8a.jpeg)

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [9 June 2021 19:15 UTC](https://discourse.nodered.org/t/two-mqtt-in-to-sqlite/46880/22 "2021-06-09T19:15:30Z")

</div>

can you attach your flow to a reply.

---

<div class="post-metadata">

### Author: ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)
#### Post date: [9 June 2021 19:34 UTC](https://discourse.nodered.org/t/two-mqtt-in-to-sqlite/46880/23 "2021-06-09T19:34:02Z")

</div>

> [@jjcfrank](#):
>
> I've noticed the readings are duplicated

Hi .. maybe its due to the **"and every subsequent message"** setting you have checked in your Join node.  
by unckecking it, you tell the Join node to wait for both the Temperature and Humidity values to arrive from mqtt and then output a joined msg.

---

<div class="post-metadata">

### Author: ![jjcfrank](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@jjcfrank](https://discourse.nodered.org/u/jjcfrank)
#### Post date: [10 June 2021 05:48 UTC](https://discourse.nodered.org/t/two-mqtt-in-to-sqlite/46880/24 "2021-06-10T05:48:19Z")

</div>

Hi UnbornN, that solved the last little bit. Thank you guys!

---

<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: [9 August 2021 05:49 UTC](https://discourse.nodered.org/t/two-mqtt-in-to-sqlite/46880/25 "2021-08-09T05:49:04Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/two-mqtt-in-to-sqlite/46880.md?page=1)
