Skip to content

Code example for MSSQL in documentation is not thread-safe #719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
loenngre opened this issue Jun 27, 2023 · 2 comments
Open

Code example for MSSQL in documentation is not thread-safe #719

loenngre opened this issue Jun 27, 2023 · 2 comments
Labels

Comments

@loenngre
Copy link

loenngre commented Jun 27, 2023

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
@snehankekre
Copy link
Contributor

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

@loenngre
Copy link
Author

Just noting that this doesn’t appear to be fixed yet. Unfortunately, I cannot offer much assistance at the moment, but I think it may cause problems for users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants