# Fetching data from redis database

**URL:** <https://discourse.nodered.org/t/fetching-data-from-redis-database/21292>\
**Category:** General\
**Created:** [5 February 2020 05:23 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292 "2020-02-05T05:23:35Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iliyas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iliyas/32/19045_2.png) [@Iliyas](https://discourse.nodered.org/u/Iliyas)\
**Post date:** [5 February 2020 05:23 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/1 "2020-02-05T05:23:35Z")

</div>

Hello,  
I have some data in redis stored in database, how can I fetch that data from that redis in node-red  
please help me out...

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [5 February 2020 06:22 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/2 "2020-02-05T06:22:27Z")

</div>

Please try searching the flow library and the forum first. There are already several nodes available.

[https://flows.nodered.org/search?term=redis&type=node](https://flows.nodered.org/search?term=redis&type=node)

I can recommend `node-red-contrib-redis`.

---

<div class="post-metadata">

**Author:** ![Iliyas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iliyas/32/19045_2.png) [@Iliyas](https://discourse.nodered.org/u/Iliyas)\
**Post date:** [5 February 2020 06:32 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/3 "2020-02-05T06:32:37Z")

</div>

I have been using this, but how to configure this nodes and fetch the data not getting it, as I'm a newbie regarding redis

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [5 February 2020 09:06 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/4 "2020-02-05T09:06:15Z")

</div>

You say you have data in redis... did you put it there? What information have you been given about your redis database and where the data is stored?

I'm sure we can help... but at the moment you have not given enough information for us to give you any help other than point you at the redis nodes.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [5 February 2020 09:25 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/6 "2020-02-05T09:25:24Z")

</div>

That show the data you want is stored under the field name of `imwAccessToken` in a hash called `IMWhash`.

This means he raw redis command to run is `HGET IMWhash imwAccessToken` - the question is how to do that with the redis nodes.

Using the `node-red-contrib-redis` module, you have the `redis command` node. You can use that to do the `HGET` command to get the value.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/f/ef78350dd6b2a80a6892c52e14c74a1df66e49a7.png)

First you'll need to configure the server details, then set the Command to HGET and then put _something_ in the Params section. Unfortunately, at this point, I don't know how the node expects you to provide the arguments to the command. It suggests it should be an object, but I don't know how to enter the `IMWhash imwAccessToken` args to an object. The node doesn't provide _any_ help.

@kuema - have you use this node? Can you provide some guidance?

---

<div class="post-metadata">

**Author:** ![Iliyas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iliyas/32/19045_2.png) [@Iliyas](https://discourse.nodered.org/u/Iliyas)\
**Post date:** [5 February 2020 09:33 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/7 "2020-02-05T09:33:25Z")

</div>

> [@knolleary](#):
>
> -

@knolleary What we have to give in the topic/key section?

---

<div class="post-metadata">

**Author:** ![Iliyas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iliyas/32/19045_2.png) [@Iliyas](https://discourse.nodered.org/u/Iliyas)\
**Post date:** [5 February 2020 09:35 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/8 "2020-02-05T09:35:47Z")

</div>

Or if there is any alternative you can suggest me and help me out with this

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [5 February 2020 09:41 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/9 "2020-02-05T09:41:12Z")

</div>

> [@knolleary](#):
>
> @kuema - have you use this node? Can you provide some guidance?

Right at this moment I don't have access to the machine running that flow using Redis.

Yes, the docs leave room for improvement. But the example flows on [node-red-contrib-redis (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-redis) should give the general idea about its usage.

---

<div class="post-metadata">

**Author:** ![Iliyas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iliyas/32/19045_2.png) [@Iliyas](https://discourse.nodered.org/u/Iliyas)\
**Post date:** [5 February 2020 09:46 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/10 "2020-02-05T09:46:17Z")

</div>

with this flows, I had gone through I'm not able to get the data, I'm not getting what to fill in topic/key and params

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [5 February 2020 09:49 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/11 "2020-02-05T09:49:44Z")

</div>

This is my best _guess_ - I haven't used these nodes and their documentation is terrible:

- Put `IMWhash` in the Topic/Key field
- Put `["imwAccessToken"]` in the params field

If that doesn't work, leave the Topic/Key field blank, and put `["IMWhash","imwAccessToken"]` in the params field.

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [5 February 2020 10:05 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/12 "2020-02-05T10:05:42Z")

</div>

With the [HGET command](https://redis.io/commands/hget), the solution Nick (@knolleary) described should work.

"Topic/Key" is used as name of the Hash, so use `IMWhash`  
"params" is an array, in this case one element with the name of the key _in_ the hash, so `imwAccessToken`.

Took me some try/error myself back then, the docs (if you could call them that) aren't even up-to-date.

---

<div class="post-metadata">

**Author:** ![Iliyas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iliyas/32/19045_2.png) [@Iliyas](https://discourse.nodered.org/u/Iliyas)\
**Post date:** [5 February 2020 10:08 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/13 "2020-02-05T10:08:11Z")

</div>

I have worked with this both things but it didn't work out.  
I have one doubt in my system I have to install redis server?

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [5 February 2020 10:11 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/14 "2020-02-05T10:11:22Z")

</div>

I have just tested it, it works for me.

```auto
[{"id":"80433c4d.36b5a8","type":"redis-command","z":"7ebee689.bd529","server":"6d99f483.4e4f1c","command":"hget","name":"","topic":"IMWhash","params":"[\"imwAccessToken\"]","paramsType":"json","payloadType":"json","block":false,"x":560,"y":1280,"wires":[["ce325093.9c43a8"]]},{"id":"ce325093.9c43a8","type":"debug","z":"7ebee689.bd529","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":1280,"wires":[]},{"id":"88687136.c00c38","type":"inject","z":"7ebee689.bd529","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":1280,"wires":[["80433c4d.36b5a8"]]},{"id":"6d99f483.4e4f1c","type":"redis-config","z":"","name":"local","options":"{}","cluster":false,"optionsType":"json"}]

```

---

<div class="post-metadata">

**Author:** ![Iliyas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iliyas/32/19045_2.png) [@Iliyas](https://discourse.nodered.org/u/Iliyas)\
**Post date:** [5 February 2020 10:14 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/15 "2020-02-05T10:14:33Z")

</div>

I tried what @kuema have tried but I'm getting null value.

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [5 February 2020 10:19 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/16 "2020-02-05T10:19:40Z")

</div>

If it returns `null`, then there is no value for the combination of _hash_ and/or _key_. You should check the names for typos.

Otherwise, I'm out of suggestions.

---

<div class="post-metadata">

**Author:** ![Iliyas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iliyas/32/19045_2.png) [@Iliyas](https://discourse.nodered.org/u/Iliyas)\
**Post date:** [5 February 2020 10:21 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/17 "2020-02-05T10:21:59Z")

</div>

as i have shared the screenshot of it there is some value present, so why its giving us a null value

---

<div class="post-metadata">

**Author:** ![Iliyas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iliyas/32/19045_2.png) [@Iliyas](https://discourse.nodered.org/u/Iliyas)\
**Post date:** [5 February 2020 10:22 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/18 "2020-02-05T10:22:24Z")

</div>

by the way thank you for your suggestions

---

<div class="post-metadata">

**Author:** ![Iliyas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iliyas/32/19045_2.png) [@Iliyas](https://discourse.nodered.org/u/Iliyas)\
**Post date:** [5 February 2020 10:34 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/19 "2020-02-05T10:34:36Z")

</div>

Is there any alternative rather than using node we can do scripting in function node and we can get?

---

<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:** [5 April 2020 10:34 UTC](https://discourse.nodered.org/t/fetching-data-from-redis-database/21292/20 "2020-04-05T10:34:37Z")

</div>

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