I’m trying to connect a Snowflake account with st.connect
and the Streamlit secrets manager, but I cannot figure out how to pass all the required parameters to create the connection. The main issue seems to be with setting the connection_name
for Snowflake.
Have tried variations from:
st.connect("snowflake")
doesn’t seem to find secretsst.connect("snowflake", **st.secrets["snowflake"]) complains about missing
name` paramst.connect("snowflake_connection", type="snowflake", **st.secrets["snowflake"])
addedconnection_name
to secrets manager, but still does not get recognized
App is deployed in Cloud: https://performance-expectations.streamlit.app/
Github repo: GitHub - risafangs/performance-expectations
Error:
2023-11-20 05:45:23.727 Uncaught app exception
Traceback (most recent call last):
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 264, in _get_or_create_cached_value
cached_result = cache.read_result(value_key)
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_resource_api.py", line 500, 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/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 312, in _handle_cache_miss
cached_result = cache.read_result(value_key)
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_resource_api.py", line 500, 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/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
exec(code, module.__dict__)
File "/mount/src/performance-expectations/main.py", line 19, in <module>
conn = st.connection("snowflake", type="snowflake", **st.secrets["snowflake"])
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/connection_factory.py", line 312, in connection_factory
conn = _create_connection(
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/metrics_util.py", line 396, in wrapped_func
result = non_optional_func(*args, **kwargs)
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/connection_factory.py", line 94, in _create_connection
return __create_connection(name, connection_class, **kwargs)
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 212, in wrapper
return cached_func(*args, **kwargs)
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 241, in __call__
return self._get_or_create_cached_value(args, kwargs)
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 267, in _get_or_create_cached_value
return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 321, in _handle_cache_miss
computed_value = self._info.func(*func_args, **func_kwargs)
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/connection_factory.py", line 87, in __create_connection
return connection_class(connection_name=name, **kwargs)
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/connections/base_connection.py", line 71, in __init__
self._raw_instance: Optional[RawConnectionT] = self._connect(**kwargs)
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/connections/snowflake_connection.py", line 115, in _connect
raise e
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/connections/snowflake_connection.py", line 79, in _connect
return snowflake.connector.connect(**conn_kwargs)
File "/home/adminuser/venv/lib/python3.9/site-packages/snowflake/connector/__init__.py", line 54, in Connect
return SnowflakeConnection(**kwargs)
File "/home/adminuser/venv/lib/python3.9/site-packages/snowflake/connector/connection.py", line 380, in __init__
raise Error(
snowflake.connector.errors.Error: Invalid connection_name 'snowflake', known ones are []
[05:45:25] 🔄 Updated app!
[05:47:06] 🐙 Pulling code changes from Github...
2023-11-20 05:47:07.741 Uncaught app exception
Traceback (most recent call last):
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
exec(code, module.__dict__)
File "/mount/src/performance-expectations/main.py", line 19, in <module>
conn = st.connection(type="snowflake", **st.secrets["snowflake"])
TypeError: connection_factory() missing 1 required positional argument: 'name'
[05:47:07] 📦 Processing dependencies...
[05:47:07] 📦 Processed dependencies!
2023-11-20 05:47:07.747 Uncaught app exception
Traceback (most recent call last):
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
exec(code, module.__dict__)
File "/mount/src/performance-expectations/main.py", line 19, in <module>
conn = st.connection(type="snowflake", **st.secrets["snowflake"])
TypeError: connection_factory() missing 1 required positional argument: 'name
Versions:
- Streamlit 1.28.2
- Python 3.9
Appreciate any ideas/examples of how to properly create the Snowflake connection. Thanks.