# How to refresh data on fly?

**URL:** <https://community.plotly.com/t/how-to-refresh-data-on-fly/13069>\
**Category:** Dash Python\
**Created:** [August 27, 2018, 3:06pm UTC](https://community.plotly.com/t/how-to-refresh-data-on-fly/13069 "2018-08-27T15:06:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![a3801283](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@a3801283](https://community.plotly.com/u/a3801283)\
**Post date:** [August 27, 2018, 3:06pm UTC](https://community.plotly.com/t/how-to-refresh-data-on-fly/13069/1 "2018-08-27T15:06:20Z")

</div>

With Dash, I can create an interactive dashboard.

But, in most Dash apps, the data is used by a CSV file.

I want to use MySQL data, which keeps growing with time.

But I met a problem, hot to make data refresh on fly?

At the start of Dash, I need to read data from MySQL, and form it into dataframe, which used by figured.  
Once the Dash app is started, the data can not be updated, unless by restart the app.

Is there any ways to refresh the data?

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [August 27, 2018, 4:05pm UTC](https://community.plotly.com/t/how-to-refresh-data-on-fly/13069/2 "2018-08-27T16:05:36Z")

</div>

> [@a3801283](#):
>
> Once the Dash app is started, the data can not be updated, unless by restart the app.

Option 1 - Make `app.layout` a function ([Live Updates | Dash for Python Documentation | Plotly](https://dash.plot.ly/live-updates)) and set the data on page load and pass it through to different callbacks with hidden divs: [Part 4. Sharing Data Between Callbacks | Dash for Python Documentation | Plotly](https://dash.plot.ly/sharing-data-between-callbacks)  
Option 2 - Run a separate scheduling process that updates the data periodically and stores the data in Redis: [GitHub - plotly/dash-redis-celery-periodic-updates: Demo apps now maintained in https://github.com/plotly/dash-enterprise-docs](https://github.com/plotly/dash-redis-celery-periodic-updates/).

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [January 6, 2020, 9:25pm UTC](https://community.plotly.com/t/how-to-refresh-data-on-fly/13069/3 "2020-01-06T21:25:18Z")

</div>

A post was split to a new topic: [MS SQL and Dash](https://community.plotly.com/t/ms-sql-and-dash/33283)

---

<div class="post-metadata">

**Author:** ![aschmied](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aschmied/32/12813_2.png) [@aschmied](https://community.plotly.com/u/aschmied)\
**Post date:** [October 6, 2020, 6:44pm UTC](https://community.plotly.com/t/how-to-refresh-data-on-fly/13069/4 "2020-10-06T18:44:47Z")

</div>

> [@chriddyp](#):
>
> [Live Updates | Dash for Python Documentation | Plotly](https://dash.plot.ly/live-updates)

In the live-updates example, the entire plot is redrawn on every interval tick. This clears any interactions the user has had with the plot such as zooming. How can we update the data while retaining view modifications made by the user?

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [October 6, 2020, 10:08pm UTC](https://community.plotly.com/t/how-to-refresh-data-on-fly/13069/5 "2020-10-06T22:08:09Z")

</div>

> [@aschmied](#):
>
> How can we update the data while retaining view modifications made by the user?

See uirevision: [📣 Preserving UI State, like Zoom, in dcc.Graph with uirevision with Dash](https://community.plotly.com/t/preserving-ui-state-like-zoom-in-dcc-graph-with-uirevision-with-dash/15793)
