Experimental_connection rerun query

How would I force a rerun of a query done through an st.experimental_connection?

For the time being I am bypassing the default query, and implementing a query (Foo) with a
@cache_data decorator, for which I call Foo.clear().

Any better ideas on how to do this?

1 Like

Hi @Gabriel_Rudloff,

Thanks for posting!

I think your idea is good unless you have a very specific use case in mind.

You can add a ttl value of 0 to the query function like below that way no data is cached. You can adjust the time to live as much as needed to expire your cache.

def query(self, query: str, ttl: int = 0, **kwargs) -> pd.DataFrame:
        def _query(query: str, **kwargs) -> pd.DataFrame:
            cursor = self.cursor()
            cursor.execute(query, **kwargs)
            return cursor.df()
        return _query(query, **kwargs)

I hope this helps.