# Node-RED node for InfluxDB control - i need a button on NodeRED Dashboard to perform database content delete

**URL:** https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449
**Category:** General
**Created:** [20 December 2021 03:07 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449 "2021-12-20T03:07:10Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![bogi](https://avatars.discourse-cdn.com/v4/letter/b/e47774/32.png) [@bogi](https://discourse.nodered.org/u/bogi)
#### Post date: [20 December 2021 03:07 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449/1 "2021-12-20T03:07:10Z")

</div>

Hi Folks!

i know by this thread:

> [@Node-RED should empty my influxDB "test database" every 7 days](https://discourse.nodered.org/t/node-red-should-empty-my-influxdb-test-database-every-7-days/39259):
>
> Hello all, Can anyone tell me if it is possible to specify in Node-RED that all records in my database are deleted every 7 days? kind regards nilsbaurx

That retention policy feature in InfluxDB itself can control data retention. However my need is specific - i need ability to clean the data base by \one click\ action from either Node-RED Dashboard or Home assistant or using MQTT message.

Imagine I'm starting my machine and want to see its parameters during the run - i don't need to save it or keep in data base (I'm using InfluxDB). My machine is equipped with basic temperature sensors and ESP8266 which is sending data only when i use machine. I can then see on the trend it's behavior. When i finish my work i need to destroy the data base by one click - i don't want to go to influxDB CLI and search for database, deleting etc... I just need simple option to click a button on the Node-RED Dash or even better: a button on ESP8266 so when i press it ESP8266 will send MQTT message to Node-RED and the Flow will remove the content from specific database.  
Do we have a Node that will do?

Thank you.

---

<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: [20 December 2021 07:22 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449/2 "2021-12-20T07:22:23Z")

</div>

Which bit do you need a node for? The usual influx node used is node-red-contrib-influxdb.

---

<div class="post-metadata">

### Author: ![bogi](https://avatars.discourse-cdn.com/v4/letter/b/e47774/32.png) [@bogi](https://discourse.nodered.org/u/bogi)
#### Post date: [22 December 2021 01:19 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449/3 "2021-12-22T01:19:27Z")

</div>

The node that will allow me to delete the content of a specified database using i.e. MQTT message.  
The plan is: when i click button on ESP8266 module -\> it will publish a message i.e. clean "temporary\_database" -\> Node-RED Flow will get it and will tell InfluxDB to go and clear all content from database called "temporary\_database".  
By doing this i can start datalogging of the temperature of my device and see the trend on the tablet. When i finish and stop logging i can destroy the data because i'll not need it anymore. And i want to destroy that data by means of the pushbutton on my machine (meaning ESP8266 publishing MQTT message).

---

<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: [22 December 2021 07:54 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449/4 "2021-12-22T07:54:06Z")

</div>

Have you tried with the node I suggested?

---

<div class="post-metadata">

### Author: ![bogi](https://avatars.discourse-cdn.com/v4/letter/b/e47774/32.png) [@bogi](https://discourse.nodered.org/u/bogi)
#### Post date: [22 December 2021 21:26 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449/5 "2021-12-22T21:26:13Z")

</div>

i'll try to try tomorrow and will update

---

<div class="post-metadata">

### Author: ![bogi](https://avatars.discourse-cdn.com/v4/letter/b/e47774/32.png) [@bogi](https://discourse.nodered.org/u/bogi)
#### Post date: [24 December 2021 08:35 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449/6 "2021-12-24T08:35:02Z")

</div>

So i'm already sing influxdb db node as i'm collecting data from mqtt using node-red, formatting them and sending to influxdb database. Actually in my palette i have 3 inlfuxdb related nodes: influxdb in, influxdb out and influxdb batch.

I assume i have take a closer look to "influxdb out" node as i want to do something with influxdb...

From here:

> **[Manage your database using InfluxQL | InfluxDB OSS 1.8 Documentation](https://docs.influxdata.com/influxdb/v1.8/query_language/manage-database/#create-database)**
>
> Use InfluxQL to administer your InfluxDB server and work with InfluxDB databases, retention policies, series, measurements, and shards.

i found two interesting things (queries):  
CREATE DATABASE \< database neme \>  
DROP DATABASE \< database name \>  
which looks promising. But how to connect the dots? How to send CREATE DATABASE \< database name \> to influxdb? Inspecting "influxdb out" node i can only see the place to put database name/path which must be already created in influxdb. I hope you get my point: database must me created first, before i use Node-Red node "influxdb out" to query it.  
To create or drop databse i would need to use influxdb CLI somehow (at least this is how i understand it...). Is it possible from node-red?

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [24 December 2021 09:01 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449/7 "2021-12-24T09:01:19Z")

</div>

Please read the documentation for the influx db nodes.

> Queries one or more measurements in an influxdb database. The query is specified in the node configuration or in the _ **msg.query** _ property. Setting it in the node will override the _ **msg.query** _ . The result is returned in _ **msg.payload** _ .

Click on the node once and click the documentation tab in the node-red ui, it gives you details about the usage.

---

<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: [24 December 2021 12:00 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449/8 "2021-12-24T12:00:04Z")

</div>

I would use DROP MEASUREMENT or DELETE \* FROM ...

If that is the right syntax for delete, I would have to check. I am not sure if you can do DROP via the influx node.

---

<div class="post-metadata">

### Author: ![bogi](https://avatars.discourse-cdn.com/v4/letter/b/e47774/32.png) [@bogi](https://discourse.nodered.org/u/bogi)
#### Post date: [25 December 2021 03:25 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449/9 "2021-12-25T03:25:51Z")

</div>

Please take into account language barriers. I've read documentation. This is what i do first as it is the fastest way and the right way. Everywhere i checked it is said "query" which can be translated to "request for information from database", right? I don't have data base, i need to create one using mqtt message and then destroy it the same way. So far i can see the only way to create database is using LinfluxDB CLI via Poratiner or directly in terminal of my RB Pi.

DROP MEASUREMENT will drop measurement only if i understand it correctly.  
DELETE \* FROM is interesting. Will "DELETE \* FROM \* " meaning "delete everything from particular database", work? Maybe i'll create one GPDB - General Purpose Data Base for ad hoc use.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [25 December 2021 05:31 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449/10 "2021-12-25T05:31:32Z")

</div>

Look, it is simple:

inject node:

 ![Screenshot 2021-12-25 at 06.33.17](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/8/b8b5b243fefd60ed719f431c16729bf08388dc15.jpeg)

Connect it to an influxdb-in node  
Deploy  
Click inject button

Inject node to drop:

 ![Screenshot 2021-12-25 at 06.30.23](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/7/f750edba4e24312014413bdaea479e385a3826cb.jpeg)

Connect it to the same influxdb-in node  
Deploy  
Click inject button

Query databases

 ![Screenshot 2021-12-25 at 06.34.05](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/9/f9d7ed3bb0a197e55968812e4b767c944264094f.jpeg)

Output in sequence:

 ![Screenshot 2021-12-25 at 06.34.09](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/66d7f19e042be00c1f51898c6c5c842418c55366.jpeg)

---

<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: [25 December 2021 09:01 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449/11 "2021-12-25T09:01:29Z")

</div>

If you drop and recreate the database does an Influx In or out node configured for that database reconnect correctly?

---

<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: [25 December 2021 15:32 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449/12 "2021-12-25T15:32:44Z")

</div>

Answering my own question, yes, the influx nodes do reconnect after dropping and recreating the database.

```auto
[{"id":"a882f9e675263bdb","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":1320,"wires":[["94c15495bcc3c1d4"]]},{"id":"94c15495bcc3c1d4","type":"influxdb out","z":"bdd7be38.d3b55","influxdb":"b0493664.35a528","name":"Add data","measurement":"testing_m","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":380,"y":1320,"wires":[]},{"id":"85dfcda50757cbb4","type":"catch","z":"bdd7be38.d3b55","name":"","scope":["94c15495bcc3c1d4","0742437cf425bed1","98583360a468f016"],"uncaught":false,"x":460,"y":1140,"wires":[["cc3a811aef5ea457"]]},{"id":"cc3a811aef5ea457","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":1140,"wires":[]},{"id":"628d0026307a8b23","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":1060,"wires":[["0742437cf425bed1"]]},{"id":"0742437cf425bed1","type":"influxdb in","z":"bdd7be38.d3b55","influxdb":"b0493664.35a528","name":"Create Testing","query":"CREATE DATABASE Testing","rawOutput":false,"precision":"","retentionPolicy":"","org":"organisation","x":380,"y":1060,"wires":[["152258a8ecbf50e0"]]},{"id":"152258a8ecbf50e0","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":1060,"wires":[]},{"id":"5ae05673e05dd2d5","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":1200,"wires":[["98583360a468f016"]]},{"id":"98583360a468f016","type":"influxdb in","z":"bdd7be38.d3b55","influxdb":"b0493664.35a528","name":"Drop Testing","query":"DROP DATABASE Testing","rawOutput":false,"precision":"","retentionPolicy":"","org":"organisation","x":370,"y":1200,"wires":[["33ba20e47e3bfb06"]]},{"id":"33ba20e47e3bfb06","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":1200,"wires":[]},{"id":"8be457793ed98e84","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":1380,"wires":[["1cde79013f6ac193"]]},{"id":"1cde79013f6ac193","type":"influxdb in","z":"bdd7be38.d3b55","influxdb":"b0493664.35a528","name":"read","query":"select * from testing_m","rawOutput":false,"precision":"","retentionPolicy":"","org":"organisation","x":330,"y":1380,"wires":[["b549639bf57a4a04"]]},{"id":"b549639bf57a4a04","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":1380,"wires":[]},{"id":"b0493664.35a528","type":"influxdb","hostname":"localhost","port":"8086","protocol":"http","database":"Testing","name":"","usetls":false,"tls":"ced18875.cf10b8","influxdbVersion":"1.x","url":"http://localhost:8086","rejectUnauthorized":true},{"id":"ced18875.cf10b8","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":true}]

```

---

<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: [23 February 2022 15:33 UTC](https://discourse.nodered.org/t/node-red-node-for-influxdb-control-i-need-a-button-on-nodered-dashboard-to-perform-database-content-delete/55449/13 "2022-02-23T15:33:36Z")

</div>

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