Error encountered with Streamlit to Snowflake Connector

Hi All,
I am not able to connect with Snowflake form Streamlit script on the following url:

Error Message: ForbiddenError: 250001 (08001): None: Failed to connect to DB. Verify the account name is correct: RL82382.snowflakecomputing.com:443. 000403: 403: HTTP 403: Forbidden

More Info:
a) streamlit run /Users/abu/Documents/AI_Software/Streamlit_Riaz_Resume_Neo/Snowflake_Streamlit/app.py [ARGUMENTS]

2023-02-06 11:15:23.390 Snowflake Connector for Python Version: 3.0.0, Python Version: 3.9.13, Platform: macOS-11.3.1-x86_64-i386-64bit

2023-02-06 11:15:23.390 This connection is in OCSP Fail Open Mode. TLS Certificates would be checked for validity and revocation status. Any other Certificate Revocation related exceptions or OCSP Responder failures would be disregarded in favor of connectivity.

2023-02-06 11:15:23.390 Setting use_openssl_only mode to False

b) From Debug Window:
More information from Debug window:

exception = {tuple: 3} (<class ‘snowflake.connector.errors.ForbiddenError’>, 250001 (08001): None: Failed to connect to DB. Verify the account name is correct: RL82382.snowflakecomputing.com:443. 000403: 403: HTTP 403: Forbidden, <traceback object at 0x11be50300>)

account = {str} ‘RL82382’

auth_instance = {AuthByDefault} <snowflake.connector.auth.default.AuthByDefault object at 0x11b91d820>

auth_timeout = {int} 120

body = {dict: 1} {‘data’: {‘CLIENT_APP_ID’: ‘PythonConnector’, ‘CLIENT_APP_VERSION’: ‘3.0.0’, ‘SVN_REVISION’: None, ‘ACCOUNT_NAME’: ‘RL82382’, ‘LOGIN_NAME’: ‘riazahmed’, ‘CLIENT_ENVIRONMENT’: {‘APPLICATION’: ‘streamlit’, ‘OS’: ‘Darwin’, ‘OS_VERSION’: 'macOS-11.3.1-x86_64-i

body_template = {dict: 1} {‘data’: {‘CLIENT_APP_ID’: ‘PythonConnector’, ‘CLIENT_APP_VERSION’: ‘3.0.0’, ‘SVN_REVISION’: None, ‘ACCOUNT_NAME’: ‘RL82382’, ‘LOGIN_NAME’: ‘riazahmed’, ‘CLIENT_ENVIRONMENT’: {‘APPLICATION’: ‘streamlit’, ‘OS’: ‘Darwin’, ‘OS_VERSION’: 'macOS-11.3.1-x86_64-i

database = {str} ‘PETS’

headers = {dict: 4} {‘Content-Type’: ‘application/json’, ‘accept’: ‘application/snowflake’, ‘User-Agent’: ‘PythonConnector/3.0.0 (macOS-11.3.1-x86_64-i386-64bit) CPython/3.9.13’, ‘Content-Encoding’: ‘gzip’}

mfa_callback = {NoneType} None

passcode = {NoneType} None

passcode_in_password = {bool} False

password_callback = {NoneType} None

request_id = {str} ‘1c9074c9-0c20-4dd6-baea-7d5bb509619b’

role = {NoneType} None

schema = {str} ‘PUBLIC’

self = {Auth} <snowflake.connector.auth._auth.Auth object at 0x11b91d940>

session_parameters = {dict: 2} {‘CLIENT_SESSION_KEEP_ALIVE’: True, ‘CLIENT_PREFETCH_THREADS’: 4}

timeout = {int} 120

url = {str} ‘/session/v1/login-request?request_id=1c9074c9-0c20-4dd6-baea-7d5bb509619b&databaseName=PETS&schemaName=PUBLIC&warehouse=COMPUTE_WH’

url_parameters = {dict: 4} {‘request_id’: ‘1c9074c9-0c20-4dd6-baea-7d5bb509619b’, ‘databaseName’: ‘PETS’, ‘schemaName’: ‘PUBLIC’, ‘warehouse’: ‘COMPUTE_WH’}

user = {str} ‘riazahmed’

warehouse = {str} ‘COMPUTE_WH’

c) // secrets.toml

  1. .streamlit/secrets.toml

  • [snowflake]
  1. user = “myuser” – Not actual user
  2. password = “mypassword”. – Not actual password
  3. account = “RL12345” – Not actual account
  4. warehouse = “COMPUTE_WH”
  5. database = “PETS”
  6. schema = “PUBLIC”

d) app.py coe:

  1. streamlit_app.py

  • import streamlit as st
  1. import snowflake.connector
  • Initialize connection.

  1. Uses st.experimental_singleton to only run once.

  2. @st.experimental_singleton
  3. def init_connection():
  4. return snowflake.connector.connect(
  5. **st.secrets[“snowflake”], client_session_keep_alive=True
  6. )
  • conn = init_connection()
  • Perform query.

  1. Uses st.experimental_memo to only rerun when the query changes or after 10 min.

  2. @st.experimental_memo(ttl=600)
  3. def run_query(query):
  4. with conn.cursor() as cur:
  5. cur.execute(query)
  6. return cur.fetchall()
  • rows = run_query(“SELECT * from mytable;”)
  • Print results.

  1. for row in rows:
  2. st.write(f"{row[0]} has a :{row[1]}:")

I will appreciate help to resolve this issue blocking me.

Regards, Riaz

Thanks for sharing your question! Please follow the guidelines here to format your code so it’s easier to read.

It sounds like your credentials might be incorrect – have you double-checked that you’re using the proper Snowflake credentials?

1 Like