connecting-streamlit-to-snowflake

Connect Streamlit apps to Snowflake using st.connection with parameterized queries and ttl caching.

629|85|Updated May 4, 2020
One-click install
npx skills add https://github.com/andfanilo/streamlit-echarts --skill connecting-streamlit-to-snowflake-andfanilo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: connecting-streamlit-to-snowflake
Source: https://github.com/andfanilo/streamlit-echarts/tree/main/.claude/skills/developing-with-streamlit/skills/connecting-streamlit-to-snowflake
Command: npx skills add https://github.com/andfanilo/streamlit-echarts --skill connecting-streamlit-to-snowflake-andfanilo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps Streamlit developers connect applications to Snowflake safely and efficiently, manage credentials, prevent SQL injection, cache query results, and perform session-based writes while respecting per-user permissions.

Core Features & Use Cases

  • st.connection integration: Use Streamlit's connection API to get automatic pooling, caching, and reconnection for Snowflake access.
  • Secure credential management: Store Snowflake credentials in st.secrets and keep secrets out of source control.
  • Safe querying and caching: Run parameterized queries to avoid injection and use ttl-based caching to improve performance.
  • Session writes and multi-environment support: Use connection.session for writes and define multiple named connections for staging and production.
  • Caller's rights and LLM integration: Enable caller's rights for viewer-scoped access and optionally build chat UIs using Snowflake Cortex for in-database LLM completions.

Quick Start

Use st.connection to open a Snowflake connection, run a parameterized query with ttl caching, and show the returned dataframe in your Streamlit app.

Frequently Asked Questions about connecting-streamlit-to-snowflake

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I securely connect Streamlit to Snowflake using st.connection?

To securely connect Streamlit to Snowflake, use the st.connection API for automatic pooling and store your valid Snowflake credentials in st.secrets to keep sensitive data out of source control.

How do I prevent SQL injection when querying Snowflake in Streamlit?

Prevent SQL injection in Streamlit by executing parameterized queries against your Snowflake database. This approach safely separates query logic from user input to protect your application from malicious code execution.

Can I cache Snowflake query results in Streamlit to improve app performance?

Yes, you can cache Snowflake query results in Streamlit by applying ttl-based caching. This mechanism stores query outputs temporarily, reducing redundant database calls and significantly improving application responsiveness.

How do I perform session writes to Snowflake from a Streamlit app?

Perform session writes to Snowflake by utilizing the connection.session methods within your Streamlit app. This enables session-based write operations while respecting per-user permissions through caller's rights viewer-scoped access.

Does Streamlit support multiple named Snowflake connections for staging and production?

Yes, Streamlit supports defining multiple named Snowflake connections. This allows you to configure and manage separate staging and production environments simultaneously within a single Streamlit application workflow.

Can I integrate Snowflake Cortex LLM completions into a Streamlit chat UI?

Yes, you can integrate Snowflake Cortex for in-database LLM completions. This enables you to optionally build interactive chat UIs directly in Streamlit using the large language model capabilities hosted within Snowflake.