You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation page Connect Streamlit to Microsoft SQL Server recommends using @st.cache_resource to store the pyodbc connection, but when I did (using FreeTDS) and had multiple concurrent sessions, Streamlit produced "invalid cursor state" errors. When I changed the code to store the connection in st.session_state instead, the errors stopped happening. It appears that pyodbc is not thread-safe.
The content you are editing has changed. Please copy your edits and refresh the page.
Thank you for flagging this important issue @loenngre! We can address this issue by using the recommended st.experimental_connection command to handle the connection to SQL Server like in this tutorial on Connecting to data
The documentation page Connect Streamlit to Microsoft SQL Server recommends using
@st.cache_resource
to store the pyodbc connection, but when I did (using FreeTDS) and had multiple concurrent sessions, Streamlit produced "invalid cursor state" errors. When I changed the code to store the connection inst.session_state
instead, the errors stopped happening. It appears that pyodbc is not thread-safe.Tasks
The text was updated successfully, but these errors were encountered: