I have a problem with my streamlit app. Every time the main script runs top bottom some window for connection is opening.
I tried setting the @st.cache_resource but I guess it doesn’t cache anything after the scripts reruns, just during the execution of my main file, so if I call the function 2 times it’s gonna use the cache, but if it’s reruned(basically everytime something happens in my custom component), I get an external browser page.
Is there any way to connect to snowflake just once and to reuse that even after the script reruns?
You’re on the right track with @st.cache_resource – that’s how we’d recommend caching your database connection. If your database connection is cached with st.cache_resource, it shouldn’t be rerunning when a user interacts with a custom component. If you can share a larger code snippet that includes the cached function, happy to take a look.
Yes… I have exhausted everything on this subject, I think it’s due to the fact that Snowflake closes my connection very quickly so even if I cache it and try to reuse it, second time it’s gonna be closed… Have you heard of any issue like this on snowflake? Any idea how to fix?
Isn’t a timeout just a mechanism for retries? I could set the timeout but due to the fact the connection is already closed I don’t think it’s something working…