데이터 애널리스트 업무 이해하기

스노우플레이크

도쿄뱅 2024. 9. 2. 21:13
반응형
import streamlit as st
from snowflake.snowpark.context import get_active_session

# Write directly to the app
st.title(":cup_with_straw: Customize Your Smoothie :cup_with_straw:")
st.write(
"""Choose the fruits you want in your custom Smoothie!
"""
)

from snowflake.snowpark.functions import col

session = get_active_session()
my_dataframe = session.table("smoothies.public.fruit_options").select(col('FRUIT_NAME'))
#st.dataframe(data=my_dataframe, use_container_width=True)

ingredients_list = st.multiselect('Choose up to 5 ingredients:',my_dataframe)

if ingredients_list:


ingredients_string = ''

for fruit_chosen in ingredients_list:
ingredients_string += fruit_chosen + ' '

#st.write(ingredients_string)

my_insert_stmt = """ insert into smoothies.public.orders(ingredients)
values ('""" + ingredients_string + """')"""

#st.write(my_insert_stmt)
time_to_insert = st.button('Submit Order')

if time_to_insert:
session.sql(my_insert_stmt).collect()
 
st.success('Your Smoothie is ordered!', icon="✅")

 
 
 
반응형