# Read data to buffer and write it to mysql

**URL:** <https://discourse.nodered.org/t/read-data-to-buffer-and-write-it-to-mysql/51667>\
**Category:** General\
**Created:** [29 September 2021 10:56 UTC](https://discourse.nodered.org/t/read-data-to-buffer-and-write-it-to-mysql/51667 "2021-09-29T10:56:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ELParreira](https://avatars.discourse-cdn.com/v4/letter/e/898d66/32.png) [@ELParreira](https://discourse.nodered.org/u/ELParreira)\
**Post date:** [29 September 2021 10:56 UTC](https://discourse.nodered.org/t/read-data-to-buffer-and-write-it-to-mysql/51667/1 "2021-09-29T10:56:56Z")

</div>

Hello,

I'm new to node red and I want to develop a project that consists os reading data from modbus devices (already done), and buffer the data (to csv file or buffer), after I want to save the same data do mysql(also managed to save to my sql). I need to buffer the data because I don't want to loose any data if the DB connection goes down.  
I main problem at the moment is I don't know how to clear the data once it's written to the DB. I already managed to save to file, and ringbuffer. But I'm lost with the part of managing the data while writing it to the DB.  
Any help will be appreciated.

Cheers,

P

---

<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:** [29 September 2021 11:10 UTC](https://discourse.nodered.org/t/read-data-to-buffer-and-write-it-to-mysql/51667/2 "2021-09-29T11:10:31Z")

</div>

Welcome to the forum @ELParreira

This flow should do what you want. It queues messages until they are successfully handled. It can even retain them over a node-red or system restart if that is required. Ask if you can't work out how to use it for your application.  
[https://flows.nodered.org/flow/05e6d61f14ef6af763ec4cfd1049ab61](https://flows.nodered.org/flow/05e6d61f14ef6af763ec4cfd1049ab61)

---

<div class="post-metadata">

**Author:** ![ELParreira](https://avatars.discourse-cdn.com/v4/letter/e/898d66/32.png) [@ELParreira](https://discourse.nodered.org/u/ELParreira)\
**Post date:** [29 September 2021 12:52 UTC](https://discourse.nodered.org/t/read-data-to-buffer-and-write-it-to-mysql/51667/3 "2021-09-29T12:52:21Z")

</div>

Perfect. Thank you Colin. I hope with time I get better with node red.  
Cheers

---

<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:** [13 October 2021 12:52 UTC](https://discourse.nodered.org/t/read-data-to-buffer-and-write-it-to-mysql/51667/4 "2021-10-13T12:52:51Z")

</div>

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