docs
docs copied to clipboard
Code example for MSSQL in documentation is not thread-safe
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.
### Tasks
- [ ] Use `st.experimental_connection` in SQL Server tutorial
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