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…
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.