AgentSkillsCN

snowflake

查询并管理Snowflake云数据仓库——运行SQL、探索表结构、管理仓库,并加载数据。使用SnowSQL CLI。

SKILL.md
--- frontmatter
name: snowflake
description: >
  Query and manage a Snowflake cloud data warehouse — run SQL, explore schemas,
  manage warehouses, and load data. Uses the SnowSQL CLI.
metadata:
  openclaw:
    requires:
      bins: [clawdata]
    primaryEnv: SNOWSQL_ACCOUNT
    tags: [database, snowflake, sql, cloud, warehouse]

Snowflake

You can query and manage a Snowflake cloud warehouse using the snowsql CLI. Use this when the user asks about cloud-hosted data, Snowflake tables, or needs to run SQL on Snowflake.

For local DuckDB queries, use the duckdb skill. For dbt transformations, use the dbt skill.

Commands

All commands use snowsql. The connection is configured via ~/.snowsql/config or environment variables.

TaskCommand
Run a querysnowsql -q "SELECT …"
Run from filesnowsql -f query.sql
List databasessnowsql -q "SHOW DATABASES"
List schemassnowsql -q "SHOW SCHEMAS IN DATABASE <db>"
List tablessnowsql -q "SHOW TABLES IN SCHEMA <db>.<schema>"
Describe tablesnowsql -q "DESCRIBE TABLE <db>.<schema>.<table>"
List warehousessnowsql -q "SHOW WAREHOUSES"
Resume warehousesnowsql -q "ALTER WAREHOUSE <wh> RESUME"
Suspend warehousesnowsql -q "ALTER WAREHOUSE <wh> SUSPEND"
Load from stagesnowsql -q "COPY INTO <table> FROM @<stage>"
Upload to stagesnowsql -q "PUT file://<path> @<stage>"

Output options

FlagEffect
-o output_format=jsonJSON output
-o output_format=csvCSV output
-o header=falseSuppress column headers
-o friendly=falseMachine-readable output

When to use

  • User asks about Snowflake data → snowsql -q "SHOW TABLES IN …"
  • User wants to query Snowflake → snowsql -q "SELECT …"
  • User asks about warehouse costs → snowsql -q "SHOW WAREHOUSES" + check credits
  • User wants to load data into Snowflake → PUT to stage, then COPY INTO
  • User wants to check schema → snowsql -q "DESCRIBE TABLE …"

Connection

SnowSQL reads credentials from ~/.snowsql/config or these environment variables:

Env varPurpose
SNOWSQL_ACCOUNTAccount identifier (e.g. xy12345.us-east-1)
SNOWSQL_USERUsername
SNOWSQL_PWDPassword
SNOWSQL_DATABASEDefault database
SNOWSQL_SCHEMADefault schema
SNOWSQL_WAREHOUSEDefault warehouse
SNOWSQL_ROLEDefault role

You can also pass connection params inline:

bash
snowsql -a <account> -u <user> -d <database> -s <schema> -w <warehouse> -q "SELECT 1"

Examples

bash
# Check connection
snowsql -q "SELECT CURRENT_USER(), CURRENT_ROLE(), CURRENT_WAREHOUSE()"

# Explore tables
snowsql -q "SHOW TABLES IN SCHEMA analytics.public"
snowsql -q "DESCRIBE TABLE analytics.public.orders"

# Query with JSON output
snowsql -q "SELECT * FROM orders LIMIT 5" -o output_format=json

# Load a local CSV
snowsql -q "PUT file://./data/sales.csv @my_stage"
snowsql -q "COPY INTO sales FROM @my_stage FILE_FORMAT=(TYPE=CSV SKIP_HEADER=1)"

Error recovery

ProblemFix
snowsql: command not foundInstall: brew install --cask snowflake-snowsql or download
Auth failureCheck ~/.snowsql/config or SNOWSQL_* env vars
Warehouse suspendedsnowsql -q "ALTER WAREHOUSE <wh> RESUME"
Database not foundsnowsql -q "SHOW DATABASES" to see available databases

Notes

  • SnowSQL exits with code 1 on failure
  • Use -o friendly=false -o header=false for cleanest machine-parseable output
  • For large queries, write SQL to a file and use snowsql -f file.sql
  • Snowflake charges per-second for active warehouses — suspend when done