Skip to content
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

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

Open
1 task
loenngre opened this issue Jun 27, 2023 · 1 comment
Open
1 task

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

loenngre opened this issue Jun 27, 2023 · 1 comment
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

@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

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