# Mqtt input to an sql DB

**URL:** <https://discourse.nodered.org/t/mqtt-input-to-an-sql-db/63621>\
**Category:** General\
**Tags:** node-red-dashboard, database, function-node\
**Created:** [8 June 2022 13:46 UTC](https://discourse.nodered.org/t/mqtt-input-to-an-sql-db/63621 "2022-06-08T13:46:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bill210kouk](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@bill210kouk](https://discourse.nodered.org/u/bill210kouk)\
**Post date:** [8 June 2022 13:46 UTC](https://discourse.nodered.org/t/mqtt-input-to-an-sql-db/63621/1 "2022-06-08T13:46:40Z")

</div>

Hello!  
I am having trouble importing the mqtt input of a published message to a table in my sql Database  
How this it build mqtt input to a function and then to the sql server?  
Mqtt -\> template -\> sql server ?  
And how the mqtt message is gonna be formatted all information to a single publish  
or splitted?

Mqtt input arrives on a textbox and i can display them but my whole thing is to be in position to insert them to the Sql server

Soon i Will provide screenshots about it!  
thanks

---

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [9 June 2022 10:02 UTC](https://discourse.nodered.org/t/mqtt-input-to-an-sql-db/63621/2 "2022-06-09T10:02:20Z")

</div>

The queries needs to be the msg.topic (for most sql BD nodes).

What flavor of sql DB are you using? (mysql, sqllight.......)

If you post a bit more information, like your json from the mqtt node, do you want to insert or select data, what your DB looks like etc. we might be able to assist you.

---

<div class="post-metadata">

**Author:** ![bill210kouk](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@bill210kouk](https://discourse.nodered.org/u/bill210kouk)\
**Post date:** [10 June 2022 07:31 UTC](https://discourse.nodered.org/t/mqtt-input-to-an-sql-db/63621/3 "2022-06-10T07:31:31Z")

</div>

Have a Nice Day. Hope you're fine!  
Im going to upload The flow after i finish from the office.  
Im using mysql and the trouble im getting is to theinsert query.  
The DB schema consists of a table with 5 columns  
Id State Current Email Timestamp.  
The Mqtt message that is published is a string and i want to insert the message to the table.  
Thats a brief description  
Thanks.

---

<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 2022 07:32 UTC](https://discourse.nodered.org/t/mqtt-input-to-an-sql-db/63621/4 "2022-08-09T07:32:25Z")

</div>

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