In the first two parts of this series, most of my work happened inside Snowflake.
I loaded files, created tables, queried data and then learned how Snowflake handles JSON.
The next badge introduced something different.
Instead of only working with the data myself, I started building something another person could actually use:
a smoothie ordering application.
Before looking at any code, I think the easiest way to understand this is to first see what we are actually building.

The finished application lets the user:
- enter their name
- choose up to five ingredients
- see information about those ingredients
- submit their order
There is actually quite a lot happening behind what looks like a simple screen.
The finished version uses things such as:
Streamlit, Python, Snowflake, Snowpark, an API, Pandas and GitHub.
When I first saw all of those pieces together, that was the part I found confusing.
I could follow individual lines of code, but I was not always clear on the bigger question:
Where is the data coming from, where is it going, and what is each tool actually doing?
So rather than starting with lots of code, I want to start with the application itself and work backwards.
In this post I will focus on the foundation:
User → Streamlit → Python → Snowflake
We will look at both:
the code we write
and
what that code actually creates in the application.
You may notice that my finished app also displays nutrition information.
I am deliberately leaving that part until the next post.
That is where we will introduce APIs and JSON and see how Python can request information from another system and bring it into our Streamlit app.
For now, the first question is:
How does a user interact with Snowflake data through a Streamlit application?
The big picture first
Before looking at the individual commands, this is the flow I needed to understand.
When the application needs to show available fruits:
SNOWFLAKE
↓
PYTHON
↓
STREAMLIT
↓
USER
But when the user submits an order, the information travels the other way:
USER
↓
STREAMLIT
↓
PYTHON
↓
SNOWFLAKE
That is the main idea behind the application.
Information is moving between different components.

Once I understood those roles, the individual lines of code stopped feeling quite so random.
Step 1: Start with something the user can see
At the beginning of the Python file we import Streamlit:
import streamlit as st
The important part for now is:
as st
This means we can use the shorter name:
st
instead of writing streamlit every time.
That is why many of the commands in the application begin with:
st.
For example:
st.title(":cup_with_straw: Customize Your Smoothie! :cup_with_straw:")
CODE
st.title(":cup_with_straw: Customize Your Smoothie! :cup_with_straw:")
RESULT IN THE APP
🥤 Customize Your Smoothie! 🥤
So I now read:
st.title(...)
as:
Streamlit, display this as a title in my application.
This is a very simple example, but it shows the basic idea behind Streamlit.
We write Python.
Streamlit turns it into something the user can see.

Step 2: Let the user enter information
A useful application also needs the user to interact with it.
My app contains:
name_on_order = st.text_input('Name on Smoothie:')
This creates the text box we can see in the application.
CODE
name_on_order = st.text_input('Name on Smoothie:')
RESULT
Name on Smoothie:
[ Zain __________________ ]
But there is something more important happening behind the screen.
If I type:
Zain
Streamlit captures that value.
Because I wrote:
name_on_order =
Python stores the answer inside a variable called:
name_on_order
So conceptually:
USER TYPES
"Zain"
↓
STREAMLIT CAPTURES IT
↓
PYTHON STORES IT
name_on_order = "Zain"
This was an important point for me.
Streamlit is not only displaying information.
It is also a way of collecting information from the user and passing it into Python.
My code then contains:
st.write(
'The name on your Smoothie will be:',
name_on_order
)
So when I type:
Zain
the application displays:
The name on your Smoothie will be: Zain
We already have our first little flow:
USER
↓
STREAMLIT TEXT BOX
↓
PYTHON VARIABLE
↓
STREAMLIT DISPLAYS IT

Step 3: Now we need Snowflake
So far our application only involves:
USER ↔ STREAMLIT ↔ PYTHON
But the fruit choices are stored in Snowflake.
The next thing we need is a way for Python to communicate with Snowflake.
In the finished external version of my application I use:
cnx = st.connection("snowflake")
session = cnx.session()
When I first saw terms such as connection and session, they sounded more complicated than they really were.
I now think of it like this:
PYTHON
↓
CONNECTION
↓
SNOWFLAKE
First:
cnx = st.connection("snowflake")
means roughly:
Connect my Streamlit application to Snowflake.
Then:
session = cnx.session()
gives Python a Snowflake session.
The simplest way I think about a session is:
An active route that allows my Python code to communicate with Snowflake.
Once we have the session, Python can start asking Snowflake for data.
Why did my connection code change?
This was one of the things that confused me during the badge.
Originally, the Streamlit application was running inside Snowflake.
The code used:
from snowflake.snowpark.context import get_active_session
session = get_active_session()
Later, I moved the application outside Snowflake.
My GitHub version uses:
cnx = st.connection("snowflake")
session = cnx.session()
At first this looked like we were doing something completely different.
But the purpose is actually the same.
We need:
A Snowflake session that Python can use to communicate with Snowflake.
What changed was where the application was running.
Inside Snowflake
APPLICATION IS ALREADY IN SNOWFLAKE
↓
GET EXISTING ACTIVE SESSION
External Streamlit application
APPLICATION IS OUTSIDE SNOWFLAKE
↓
CREATE CONNECTION
↓
GET SNOWFLAKE SESSION
The syntax changed.
The purpose did not.

Step 4: Ask Snowflake for the fruit choices
Now Python has a route into Snowflake.
The next thing we need is the list of fruits the user can select.
My final application contains:
my_dataframe = session.table(
"smoothies.public.fruit_options"
).select(
col('FRUIT_NAME'),
col('SEARCH_ON')
)
There is an extra column called:
SEARCH_ON
in my finished version.
That becomes important when we introduce the API, so I will explain it properly in another post.
For now, focus on:
FRUIT_NAME
First:
session.table(
"smoothies.public.fruit_options"
)
means:
Using my Snowflake session, go to this Snowflake table.
Then:
.select(
col('FRUIT_NAME')
)
means:
From that table, I want the FRUIT_NAME information.
The result is stored in:
my_dataframe
So:
SNOWFLAKE
FRUIT_OPTIONS TABLE
↓
Python requests FRUIT_NAME
↓
my_dataframe
What is a DataFrame?
This was another term that initially sounded more technical than it needed to.
For now, the easiest way I think about a DataFrame is:
A table-like object that Python can work with.
For example:
FRUIT_NAME
----------------
Apples
Cantaloupe
Mango
Orange
Lime
The original data lives in Snowflake.
But Python now has a way to work with that table-like data.
At this point we are using a Snowpark DataFrame.
Later in the badge I also use a Pandas DataFrame.
They are not exactly the same thing, so I will leave that distinction for a later post rather than mixing everything together here.
Step 5: Turn Snowflake data into something the user can select
Now we start connecting the pieces together.
My application contains:
ingredients_list = st.multiselect(
"Choose up to 5 ingredients:",
my_dataframe,
max_selections=5
)
CODE
ingredients_list = st.multiselect(
"Choose up to 5 ingredients:",
my_dataframe,
max_selections=5
)
RESULT IN MY APP
Choose up to 5 ingredients:
[Apples] [Cantaloupe] [Mango] [Orange]
This is where only looking at the Python code can hide what is really happening.
Those fruit choices did not magically appear inside Streamlit.
They travelled through the application:
FRUIT_OPTIONS TABLE
IN SNOWFLAKE
↓
Python uses session.table()
↓
my_dataframe
↓
st.multiselect()
↓
USER SEES FRUIT CHOICES
This was one of the main moments where the idea of a data application clicked for me.
I was taking values stored in Snowflake and using them to control what appeared inside a web application.

Step 6: What happens when the user chooses fruits?
In my screenshot I selected:
Apples
Cantaloupe
Mango
Orange
Streamlit stores those selections inside:
ingredients_list
Conceptually, Python now has something similar to:
["Apples", "Cantaloupe", "Mango", "Orange"]
This is a Python list.
The application then goes through the selected fruits.
ingredients_string = ''
for fruit_chosen in ingredients_list:
ingredients_string += fruit_chosen + ' '
First:
ingredients_string = ''
means:
Start with an empty piece of text.
Then:
for fruit_chosen in ingredients_list:
means:
Go through each fruit the user selected, one at a time.
So Python effectively goes:
fruit_chosen = Apples
then
fruit_chosen = Cantaloupe
then
fruit_chosen = Mango
then
fruit_chosen = Orange
And:
ingredients_string += fruit_chosen + ' '
keeps adding each fruit onto the text.
Eventually we might have:
Apples Cantaloupe Mango Orange
So:
USER SELECTION
[Apples, Cantaloupe, Mango, Orange]
↓
PYTHON PROCESSES LIST
↓
"Apples Cantaloupe Mango Orange"
Now we have something that can be stored as part of the order.
Step 7: Give the user a Submit button
My application also contains:
time_to_insert = st.button('Submit Order')
RESULT
[ Submit Order ]
The code then uses:
if time_to_insert:
which basically means:
If the user has pressed Submit Order, run the code underneath.
So the button controls when Python performs the next action.
Step 8: Send the order back into Snowflake
At this stage Python has things such as:
name_on_order = "Zain"
and:
ingredients_string =
"Apples Cantaloupe Mango Orange"
We now want to save those values into the Snowflake ORDERS table.
The code builds an SQL statement similar to:
my_insert_stmt = """
insert into smoothies.public.orders
(ingredients, name_on_order)
values ('""" + ingredients_string + """','""" + name_on_order + """')
"""
When I first looked at this, the mixture of quotes made it look much more complicated than the idea behind it.
What Python is effectively creating is:
INSERT INTO smoothies.public.orders
(ingredients, name_on_order)
VALUES (
'Apples Cantaloupe Mango Orange',
'Zain'
);
Which simply means:
Add a new row to the ORDERS table containing this person's name and selected ingredients.
Python then sends the SQL to Snowflake:
session.sql(my_insert_stmt).collect()
The important flow is:
USER PRESSES SUBMIT
↓
PYTHON HAS NAME + INGREDIENTS
↓
PYTHON CREATES SQL INSERT
↓
SQL SENT TO SNOWFLAKE
↓
NEW ORDER STORED
The workshop builds the SQL directly from the user's values so that the process is easy to see.
In a production application, I would normally use a safer parameterised approach when dealing with user-entered values rather than directly joining user input into SQL.
Step 9: Tell the user their order was successful
After Snowflake receives the order, Streamlit can display a confirmation.
st.success(
'Your Smoothie is ordered, '
+ name_on_order + '!',
icon="✅"
)
If:
name_on_order = Zain
the application can display:
✅ Your Smoothie is ordered, Zain!
We have now completed the full journey:
USER
enters name + chooses fruits
↓
STREAMLIT
captures those choices
↓
PYTHON
processes them
↓
SNOWFLAKE
stores the order
↓
STREAMLIT
confirms it worked

The important idea: READ vs WRITE
This was probably the simplest way for me to understand the whole application.
READ
When the app needs the available fruits:
SNOWFLAKE
↓
PYTHON
↓
STREAMLIT
↓
USER
The application is reading from Snowflake.
WRITE
When the user submits an order:
USER
↓
STREAMLIT
↓
PYTHON
↓
SNOWFLAKE
The application is writing to Snowflake.

Where does GitHub fit?
The finished application now lives inside my GitHub repository.
This introduced another useful distinction.
GITHUB
= application CODE
SNOWFLAKE
= application DATA
GitHub stores and tracks files such as:
streamlit_app.py
and:
requirements.txt
The Python file contains the application code.
The requirements file tells the environment which Python packages the application needs.
My finished application uses:
snowflake-snowpark-python
streamlit
requests
pandas
I am deliberately not explaining requests and pandas yet.
Those become important when we look at the API section of the application.
What about passwords?
Because the external Streamlit application connects to Snowflake, it needs connection information.
But I do not want things such as my Snowflake password written directly inside:
streamlit_app.py
especially if that file is stored publicly on GitHub.
Instead, these values are stored separately as secrets.
I think of secrets as:
A locked drawer containing information the application needs but should not expose publicly.
So:
PUBLIC APPLICATION CODE
↓
needs Snowflake connection
↓
SECRETS PROVIDE CREDENTIALS
↓
SNOWFLAKE
The complete application flow
We started with a simple goal:
Let someone order a smoothie without needing to know Python or SQL.
Behind that simple interface:
1. User opens the Streamlit app
↓
2. Python connects to Snowflake
↓
3. Python retrieves the available fruits
↓
4. Streamlit displays those fruits
↓
5. User enters their name
↓
6. User selects ingredients
↓
7. Streamlit passes those values to Python
↓
8. User presses Submit
↓
9. Python sends an INSERT to Snowflake
↓
10. Snowflake stores the order
↓
11. Streamlit confirms the order

The concepts I would remember
Streamlit — creates the interface the user sees and interacts with.
Python — controls the application logic and connects the different parts together.
Snowflake — stores and returns the application's data.
Snowpark — allows Python to work with Snowflake.
Session — the active route Python uses to communicate with Snowflake.
GitHub — stores and tracks the application code.
Secrets — keep sensitive connection information away from the public code.
Final takeaway
The biggest thing I learned from this part of the badge was not memorising every Streamlit or Snowpark function.
It was understanding:
Where is the information coming from, where is it going, and what is moving it?
The simplest version is:
USER
↓
STREAMLIT
↓
PYTHON
↓
SNOWFLAKE
And when we retrieve information, it travels back:
SNOWFLAKE
↓
PYTHON
↓
STREAMLIT
↓
USER
Once I understood that flow, the code stopped looking like a collection of random commands.
Each line had a reason for being there.
My finished application contains another important part that I have deliberately not explained in this post.
When I choose Apples, for example, the application can display:
Apples Nutrition Information.
That information does not come from my Snowflake FRUIT_OPTIONS table.
Python requests it from another system using an API.
That is what I will explore in the next part:
What is an API, what does requests.get() actually do, and how does JSON data from another system end up appearing inside a Streamlit application?
