Code example for MSSQL in documentation is not thread-safe

Open Beginner friendly
#719 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
python, sql

Research direction

Start with the Connect Streamlit to Microsoft SQL Server documentation page and review its current connection example. Replace the cached pyodbc connection as requested with st.experimental_connection, then verify that the example addresses concurrent sessions without the reported invalid cursor state errors.

Written by the indexing model from the issue text.

Description

docs

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
Dominant language
JavaScript
Stars
178
Forks
705
Avg merge
1d 13h
Merged PRs (30d)
39

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from streamlit/docs

All issues in streamlit/docs

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.