Help with Snowflake Connection

I’m trying to connect my streamlit application with some sql database that Snowflake owns. Clearly I have problems entering the data… can you help me?

The error is “ForbiddenError: 250001 (08001): Failed to connect to DB. Verify the account name is correct: ltb39995.snowflakecomputing.com:443. 000403: HTTP 403: Forbidden”
(bug to find the url?)

The secrets.toml (in folder .streamlit) is:

[connections.snowpark]
account = "(1)"
user = "(2)"
password = "(password)"
role = "ACCOUNTADMIN"
warehouse = "COMPUTE_SH"
database = "GLOBAL_DEFAULT_RISK_MONITOR"
schema = "DATA"
client_session_keep_alive = true

(1) Account, is ok? (“ltb39995”)
Captura de Pantalla 2023-05-03 a la(s) 21.56.44

(2) Username, is it ok?
Captura de Pantalla 2023-05-03 a la(s) 21.57.52

(3) The role and warehouse.
Captura de Pantalla 2023-05-03 a la(s) 22.00.41

And the code of home page:

import streamlit as st
#import snowflake.connector as sf
import pandas as pd

# Initialize connection with experimental connection
conn = st.experimental_connection('snowpark')

# Read database
df = conn.query('select * from DATA.DEFAULT_PROBABILITY;', ttl=600)

# View results.
for row in df.itertuples():
    st.write(pd.DataFrame(df))

I was looking for and applying various ways to make the connection work, but I can’t find the reason for the failure. I cant find error :frowning:

Thanks!

Hi @tinserrano

Thanks for your question. It seems in your secrets.toml you’ve specified COMPUTE_SH as the warehouse name, but from the screenshot it is COMPUTE_WH

In the last line of the code, could you try printing out values from the rows (currently you’ve specified df). Please refer to the Streamlit Docs for example (e.g. st.write(f"{row.NAME} has a :{row.PET}:") where NAME and PET are column names, thus please replace these with column names from your database.)

Hope this helps!

Best regards,
Chanin

Hello Chanin! It is a great pleasure to know that you answered me :slight_smile: Thanks for sharing the typo, but it continues with the same error… although now it tells me that it is an account problem. In Snowflake, do I have to put something somewhere so that it can read the SQL from outside? Thank you!

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

Martin

Hi @tinserrano

My pleasure! I have contacted a colleague from the Snowflake side to help and will get back to you as soon as I get a solution to this issue.

Best regards,
Chanin

Hi @tinserrano!
Your Snowflake URL should have this syntax:
orgname-accountname.snowflakecomputing.com

An easy way to retrieve it would be to click Classic Console on your Snowflake UI and copying that link. Hope this helps!

2 Likes

It’s also in the bottom left of the home window in SnowSight :slight_smile:
image

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.