I have a dashboard that works as follows:
- User selects an item from a dropdown menu
- A database is queried to pull the data (as a dataframe) based on the users’s choice
- Three different plots are created using the same dataframe
- When the user selects a different item, steps 2 and 3 are rerun
Now my problem is, I am querying the database with exactly the same query to pull the data for all three app.callback decorators corresponding to the three plots I have. This is very inefficient and I want to figure out a way to query the database once and then share the dataframe between the decorators.
I am thinking of defining the dataframe as global but I feel there may be a cleaner solution.
Any pointer will be appreciated.