This repository contains a Streamlit app that integrates with Snowflake to display and manage data. The setup includes creating a virtual environment, installing necessary dependencies, and using SnowSQL for database operations.
-
Ensure you have Python installed. You can check by running:
python3 --version
-
Create a virtual environment:
python3 -m venv venv
-
Activate the virtual environment:
-
macOS/Linux:
source venv/bin/activate
-
Windows:
venv\Scripts\activate
-
-
Install the required Python packages:
pip install streamlit pandas
-
Add these dependencies to
requirements.txt
:streamlit pandas snowflake-connector-python python-dotenv
-
Install the dependencies:
pip install -r requirements.txt
-
Install SnowSQL (for macOS using Homebrew):
brew install --cask snowflake-snowsql
-
Verify the installation:
snowsql --version
-
Connect to Snowflake using SnowSQL:
snowsql -a <account_name> -u <username> -d <database_name> -s <schema_name>
-
Create a
.env
file in your project root to store Snowflake credentials:SNOWFLAKE_USER=your_username SNOWFLAKE_PASSWORD=your_password SNOWFLAKE_ACCOUNT=your_account SNOWFLAKE_WAREHOUSE=your_warehouse SNOWFLAKE_DATABASE=your_database SNOWFLAKE_SCHEMA=your_schema
-
Create a Database:
Run the following command in SnowSQL to create a new database:
CREATE DATABASE test_db;
-
Create a Schema:
After creating the database, create a schema within that database:
USE DATABASE test_db; CREATE SCHEMA my_schema;
-
Create a Table:
Now create a table within the schema to store user data:
USE SCHEMA vida_schema; CREATE TABLE user ( id INTEGER, name STRING, created_on TIMESTAMP );
-
Insert Initial Data:
Optionally, insert some initial data into the
user
table:INSERT INTO user (id, name, created_on) VALUES (1, 'Alice', CURRENT_TIMESTAMP), (2, 'Bob', CURRENT_TIMESTAMP), (3, 'Kenneth', CURRENT_TIMESTAMP);
-
To start the Streamlit app, run:
streamlit run app.py
-
Open your browser to
http://localhost:8501
to see the app.
- The app connects to a Snowflake database and displays data from a
user
table. - Users can add new entries to the
user
table via a form in the Streamlit app. - The app uses a
.env
file to securely store Snowflake credentials.
-
Activate virtual environment:
source venv/bin/activate
-
Deactivate virtual environment:
deactivate
-
Install dependencies:
pip install -r requirements.txt
-
Run Streamlit app:
streamlit run app.py
-
Connect to Snowflake with SnowSQL:
snowsql -a <account_name> -u <username> -d <database_name> -s <schema_name>
This README.md
file documents the setup and usage of the Streamlit app with Snowflake integration. It covers everything from setting up a virtual environment and connecting to Snowflake, to creating the necessary database, schema, and table. :)