From the course: Intro to Snowflake for Devs, Data Scientists, Data Engineers
Unlock this course with a free trial
Join today to access over 24,600 courses taught by industry experts.
Streamlit in Snowflake: Part 2 - Snowflake Tutorial
From the course: Intro to Snowflake for Devs, Data Scientists, Data Engineers
Streamlit in Snowflake: Part 2
- We left off just when things were starting to get interesting. We were about to define the two functions that run the SQL queries to pull the data we need. Let's talk about that now. First, we'll hide the app for a moment so we can see the code full screen. Okay, for the first function, you give it a list of city names and a start year and an end year, and it will calculate the total order value for each day in that range for each of those cities, you'll notice that it generates the SQL dynamically. You can see city names, start year, and end year inside the curly brackets. Then it converts the result to pandas and returns that plus the text of the SQL query that you use to generate that data. The next function get unique cities is much simpler. It takes no arguments and we'll use it later to generate the city dropdown menu. Each of these two functions has an ST dot Cache dot data operator above it, which just means that Streamlit will pay attention to whether you've already run…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.