# Node-RED select sqlite db and transform the date into an object with arrays

**URL:** https://discourse.nodered.org/t/node-red-select-sqlite-db-and-transform-the-date-into-an-object-with-arrays/18467
**Category:** General
**Created:** [26 November 2019 15:21 UTC](https://discourse.nodered.org/t/node-red-select-sqlite-db-and-transform-the-date-into-an-object-with-arrays/18467 "2019-11-26T15:21:18Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Argon](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@Argon](https://discourse.nodered.org/u/Argon)
#### Post date: [26 November 2019 15:21 UTC](https://discourse.nodered.org/t/node-red-select-sqlite-db-and-transform-the-date-into-an-object-with-arrays/18467/1 "2019-11-26T15:21:18Z")

</div>

Hi,

To start with, i'm not a pro coder and rather love it to try new things. So some things that i'm saying here could be completly wrong or maybe i'm trying things that are not seen as best practice. 😉

I'm filling a sqlite DB (called test.db) with some cryptocurrency data:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c933cb26b066c66c04717d6ff7e14bfafd1be8f9.png)

Now my goal is to export that data from SQLite into a Object with arrays (high, low, close) like seen in this printscreen:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7158ef8330a0f096b3af9c865e57289b78b24eb7.png)

I'm using another Node-Red module called "node-red-contrib-talib" to calculate indicators from specific cryptocurrency coins. Node-Red-contrib-talib expects to receive data like the above printscreen.

Anyone here that can help me or can give me some hints how to achieve this?

Thanks!

---

<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: [26 November 2019 22:27 UTC](https://discourse.nodered.org/t/node-red-select-sqlite-db-and-transform-the-date-into-an-object-with-arrays/18467/2 "2019-11-26T22:27:58Z")

</div>

Is it always 15 values? I assume that is 1 day's worth?

---

<div class="post-metadata">

### Author: ![Argon](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@Argon](https://discourse.nodered.org/u/Argon)
#### Post date: [27 November 2019 07:20 UTC](https://discourse.nodered.org/t/node-red-select-sqlite-db-and-transform-the-date-into-an-object-with-arrays/18467/3 "2019-11-27T07:20:46Z")

</div>

Hi,

not necessary. It depends on which Indicator you want to calculate. But most of the times I need the last 5 a 15 values from each column.

Thanks!

---

<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: [27 November 2019 23:30 UTC](https://discourse.nodered.org/t/node-red-select-sqlite-db-and-transform-the-date-into-an-object-with-arrays/18467/4 "2019-11-27T23:30:29Z")

</div>

Well, just a guess but I think that I'd probably write 3 SQL queries, 1 for each column then combine the output.

---

<div class="post-metadata">

### Author: ![jrbou](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jrbou](https://discourse.nodered.org/u/jrbou)
#### Post date: [2 January 2022 06:54 UTC](https://discourse.nodered.org/t/node-red-select-sqlite-db-and-transform-the-date-into-an-object-with-arrays/18467/5 "2022-01-02T06:54:08Z")

</div>

Hi Argon

I did it using a query for each column, second using the node Join I load all them into an array, next I wrote a function to format the array in string with json format and finally I use the node Json to parse it.

Good luck !

---

<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: [2 January 2022 09:17 UTC](https://discourse.nodered.org/t/node-red-select-sqlite-db-and-transform-the-date-into-an-object-with-arrays/18467/6 "2022-01-02T09:17:11Z")

</div>


