Newbie question - Can streamlit get data on a per request basis?

Hi,
Iโ€™d like to build an app which gets the data from the server for each change in selector.
so they select another value, and then you go and get the data.

Is there any data / api layer already existing to do this? I donโ€™t like the idea that the whole dataset is loaded up front!

Thanks,
Dan

Hi @codek, welcome to the Streamlit community!

Yes, you can do the behavior you describe. You donโ€™t have to load an entire dataset up front. The behavior you are describing sounds like one where youโ€™d query a database or similar to get values as they change.

To avoid thrashing the database, you would want to use our caching decorator @st.cache to save the results of your queries, so that 2 or more runs with the same input arguments loads the data from RAM instead of re-running the same query over and over.

1 Like

Excellent thanks!