docs icon indicating copy to clipboard operation
docs copied to clipboard

Code example for MSSQL in documentation is not thread-safe

Open loenngre opened this issue 1 year ago • 1 comments

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

loenngre avatar Jun 27 '23 12:06 loenngre

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

snehankekre avatar Jul 20 '23 10:07 snehankekre