2023-03-08 09:01:28.172 Thread 'MainThread': missing ScriptRunContext
2023-03-08 09:01:28.173 Thread 'MainThread': missing ScriptRunContext
2023-03-08 09:11:54.661 Uncaught app exception
Traceback (most recent call last):
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 235, in get_or_create_cached_value
result = cache.read_result(value_key)
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/singleton_decorator.py", line 276, in read_result
raise CacheKeyNotFoundError()
streamlit.runtime.caching.cache_errors.CacheKeyNotFoundError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 563, in _run_script
exec(code, module.__dict__)
File "/app/ocr-alma/pages/3_QC OCR.py", line 32, in <module>
conn = init_connection()
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 281, in wrapper
return get_or_create_cached_value()
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 252, in get_or_create_cached_value
return_value = func(*args, **kwargs)
File "/app/ocr-alma/pages/3_QC OCR.py", line 21, in init_connection
return pyodbc.connect(
pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
We are using MS SQL Server for our app to save and extract data. Our IT department had allowed the outbound IP address in the firewall for this to work. However, we are facing this issue.
Version:
Streamlit == 1.14.1
Python == 3.10.4
pyodbc == 4.0.32
This is the snippet of init_connection code:
@st.experimental_singleton
def init_connection():
return pyodbc.connect(
"DRIVER={ODBC Driver 17 for SQL Server};SERVER="
+ st.secrets["server"]
+ ";DATABASE="
+ st.secrets["database"]
+ ";UID="
+ st.secrets["username"]
+ ";PWD="
+ st.secrets["password"]
)
conn = init_connection()
c = conn.cursor()
# Perform query.
def insert_query(id, name):
c.execute('INSERT INTO Form (id, name) VALUES(?,?,?,?)',(id, name))
conn.commit()