Streamlit with Snowflake
Streamlit provides immense options to explore UI apps based upon snowflake. Here we will talk about the simplest app we can build using streamlit and conda.
App Usage: Get Structure of a Snowflake Object( Tables/Views)
Below are the steps involved:
- Install anaconda on your machine using : https://www.anaconda.com/download
- Upon finishing installation you can create your own enviroment for your projects or work in the base environment as well. Default is base.
- To create env use: conda create — name envname.
- To activate environment use:conda activate envname . Check your current active environment using conda info — envs
- Install the required packages for your apps in your current working environment. For this app we will be needing below 2 packages.
conda install streamlit ,conda install snowflake-connector-python
6. Post installation you can start creating your code as per your style.
Below is basic template which was used to create the app.
Part1 : Importing the objects and Creating a active snowflake connection.
Part2 : App Block & Closing the connection:
7. Save the file with any name and .py extension and run it on streamlit conda environment using — ->streamlit run path/pythonfilename
8.The browser will open with the app’s user interface, and voilà, your first app will be ready to use within seconds.
Below will be the app run output:
You can choose the object type from top list and names from the bottom list.
9. Post running stop the app using terminal regular stop prompt.
10. Deactivate Conda Environment using : conda deactivate
This is basic use-case of streamlit. Can be used in multiple ways.
References:
https://docs.streamlit.io/get-started/installation/streamlit-in-snowflake
https://docs.snowflake.com/en/developer-guide/streamlit/about-streamlit