How to refresh data on fly?

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?

1 Like

Option 1 - Make app.layout a function (Live Updates | Dash for Python Documentation | Plotly) 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
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.

A post was split to a new topic: MS SQL and Dash

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?

See uirevision: 📣 Preserving UI State, like Zoom, in dcc.Graph with uirevision with Dash

1 Like