# Extract SQL data from database

**URL:** <https://discourse.nodered.org/t/extract-sql-data-from-database/18091>\
**Category:** General\
**Created:** [18 November 2019 09:17 UTC](https://discourse.nodered.org/t/extract-sql-data-from-database/18091 "2019-11-18T09:17:19Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![foerstl](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@foerstl](https://discourse.nodered.org/u/foerstl)\
**Post date:** [18 November 2019 09:17 UTC](https://discourse.nodered.org/t/extract-sql-data-from-database/18091/1 "2019-11-18T09:17:19Z")

</div>

Hello,  
I have a Maria DB installed on my IoT2020 and I'm writing data on to it via this flow: ![NRdiscourse](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d513a91a41dc65fb64ff811009ddd8ffcf1d76f5.png)  
Everything works fine so far but now I want to display the table on the dashboard but I have no idea how to use the output from the MariaDB node. Is it somehow possible to connect a function saying SELECT \* to the input or output and get a message with an array or is their a even better way?  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [18 November 2019 10:24 UTC](https://discourse.nodered.org/t/extract-sql-data-from-database/18091/2 "2019-11-18T10:24:18Z")

</div>

It is really hard for anyone to help if you don't tell us what kind of output you want?

Have you looked in the flows library for Dashboard extensions? I believe that there is one that will build a table for you for example.

If you connect a debug node to the output of the MariaDB node, you will see what data you are getting back.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 November 2019 10:29 UTC](https://discourse.nodered.org/t/extract-sql-data-from-database/18091/3 "2019-11-18T10:29:32Z")

</div>

Do you mean you don't know how to get the data from the db or you don't know how to display it?

---

<div class="post-metadata">

**Author:** ![foerstl](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@foerstl](https://discourse.nodered.org/u/foerstl)\
**Post date:** [18 November 2019 13:58 UTC](https://discourse.nodered.org/t/extract-sql-data-from-database/18091/4 "2019-11-18T13:58:35Z")

</div>

Sorry if it was unclear. I basically know how to display it in a table on the dashboard and meanwhile I found that I get my entire data from the db as output from the SQL node if I connect the function with SELECT \* to the input.  
I looked at some flows here in the forum but I couldnt find how I can put this data into an array and show it then. The msg object looks like this:  
 ![NRpayload](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1e910f3d2b24600b5e91544bb75a7f0828dca4c9.png)  
Each object should be in a new row.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 November 2019 15:31 UTC](https://discourse.nodered.org/t/extract-sql-data-from-database/18091/5 "2019-11-18T15:31:02Z")

</div>

Start by reading the node red page on [Working with Messages](https://nodered.org/docs/user-guide/messages). That should help you understand what you need to do. Each row in the database will be one of the 4 elements of the array in msg.payload.  
Also find a primer on Mariadb or MySQL to show you how to get the data you want out of the db. MariaDB is the same sql syntax as MySQL I believe.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [18 November 2019 17:38 UTC](https://discourse.nodered.org/t/extract-sql-data-from-database/18091/6 "2019-11-18T17:38:19Z")

</div>

> [@foerstl](#):
>
> put this data into an array

It is already in an array. `msg.payload` is an array of objects. I think that you might be able to pass that direct to the ui-table node

> **[node-red-node-ui-table](https://flows.nodered.org/node/node-red-node-ui-table)**
>
> Table UI widget node for Node-RED Dashboard

---

<div class="post-metadata">

**Author:** ![foerstl](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@foerstl](https://discourse.nodered.org/u/foerstl)\
**Post date:** [22 November 2019 10:09 UTC](https://discourse.nodered.org/t/extract-sql-data-from-database/18091/7 "2019-11-22T10:09:06Z")

</div>

Thank you, this node is the sollution for my problem. Unfortunately, this node doesnt work with my node red version 0.16.2. I can install the node but as soon as I configure it and deploy it all columns are deleted and I get no output on the dashboard.  
But thanks anyways. I will wait until npm 2.6 is available for the SIMATIC IoT Gateway.

---

<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:** [22 November 2019 11:28 UTC](https://discourse.nodered.org/t/extract-sql-data-from-database/18091/8 "2019-11-22T11:28:55Z")

</div>

> [@foerstl](#):
>
> I will wait until npm 2.6 is available

npm 2.6??? I've got npm v6.13.1 running!

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [22 November 2019 17:16 UTC](https://discourse.nodered.org/t/extract-sql-data-from-database/18091/9 "2019-11-22T17:16:40Z")

</div>

> [@foerstl](#):
>
> SIMATIC IoT Gateway

I'm afraid that you will be waiting forever

> Intel Quark lacks support for certain hardware instructions required in newer versions of V8 engine that Node.js uses to run

The latest version of node.js you can run is 7.10 according to this thread:

> <https://github.com/siemens/meta-iot2000/issues/104>
>
> Hi to all,
> 
> i'm trying to build a new image with latest node 8.x version and n…pm 6.x version.
> 
> Actually i'm able to get node 8.9.4 working correctly, main problem is npm. In that case npm just return for every command an "Illegal instruction". I'm lost on that message and i really don't know how to solve it.
> 
> Are you going to support node 8.x instead of 6.x? I'm quite new to yocto builds and for me it is really time spending to build and test on physical device that everything works. Do you have any advice how to increase test phase? What do you use during yocto development to test image on correct architecture?
> 
> Thanks!

That still will prevent you from running newer versions of Node-RED and from using many nodes which typically require at least node.js v8.16

---

<div class="post-metadata">

**Author:** ![100rabhShukla](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/100rabhshukla/32/52889_2.png) [@100rabhShukla](https://discourse.nodered.org/u/100rabhShukla)\
**Post date:** [20 December 2021 05:59 UTC](https://discourse.nodered.org/t/extract-sql-data-from-database/18091/10 "2021-12-20T05:59:13Z")

</div>

it's node.js version

---

<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:** [20 December 2021 09:38 UTC](https://discourse.nodered.org/t/extract-sql-data-from-database/18091/11 "2021-12-20T09:38:19Z")

</div>


