Streamlit Cloud <--> Snowflake - doesn't deploy, but works locally

Trying to deploy an app on Streamlit, but facing a weird error without a description.

It’s extremely basic - Snowpark connects to Snowflake, reads from a view and renders two plotly graphs. It works very well on my local machine but does this on the cloud.

I’m running Python 3.8.13 for Snowpark. Any insight is appreciated. Thanks in advance!

Hi @VinodShiv, welcome to the Streamlit community!

Is there a code sample you can share that demonstrates this?

Best,
Randy

Thanks @randyzwitch, here’s a sample:

tot_sql = "SELECT\
DATE_TRUNC('DAY', STARTTIME) START_DAY, COUNT(*) AS NUM_TRIPS\
FROM TRIPS_VW\
GROUP BY 1\
ORDER BY 1;"

tot_df = session.sql(tot_sql).to_pandas()

st.markdown('\n##### Trips over Time')
fig = px.area(tot_df, x="START_DAY", y="NUM_TRIPS")
st.plotly_chart(fig)

This gives me something like this locally:

I guess it’s the snowflake.snowpark Session doesn’t work on Streamlit cloud. Try using snowflake.connector instead.

import snowflake.connector

cnn = snowflake.connector.connect(**)

tot_sql = “SELECT
DATE_TRUNC(‘DAY’, STARTTIME) START_DAY, COUNT(*) AS NUM_TRIPS
FROM TRIPS_VW
GROUP BY 1
ORDER BY 1;”

cur = cnn.cursor()
cur.execute(tot_sql)

tot_df = cur.fetch_pandas_all()

cur.close()
cnn.close()

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