liveBook · Manning

Snowflake CLI

As explained in Snowflake Data Engineering

Snowflake CLI is a command-line tool for interacting with Snowflake and performing tasks such as file uploads and connection tests.

Snowflake CLI is an open-source command-line tool for executing Snowflake code from an IDE and from continuous-integration workflows. It provides a shared command surface for testing scripts during development and running committed repository code after deployment steps. section 15.4 section 15.7

Install the Python package with pip after installing Python 3.8 or later. Configure a named default connection in ~/.snowflake/config.toml with the Snowflake account, user, password, database, warehouse, and role; then verify it with a connection test. Command options can supply connection parameters, but a configuration file avoids repeating them. section 15.4.1

default_connection_name = "my_connection"

[connections.my_connection]
account = "<your Snowflake account>"
user = "<your username>"
password = "<your password>"
database = "BAKERY_DB"
warehouse = "BAKERY_WH"
role = "DATA_ENGINEER"

A default config.toml connection centralizes the account and execution context used by snow commands. section 15.4.1

Verify the installation and connection

Run snow --help to confirm that the CLI is available, then run snow connection test to return the configured account, user, role, database, warehouse, and connection status. section 15.4.1

Use two execution paths as a pipeline moves toward integration:

  • Test an individual local SQL file from the IDE with snow sql -f and its path. This supports repeated development-time checks of object-creation scripts. section 15.4.2
  • Fetch the latest repository files into a Snowflake Git repository stage with snow sql -q, then run a staged script through EXECUTE IMMEDIATE FROM. section 15.4.2
  • Use the same CLI commands in continuous integration after changes are reviewed, committed, and merged into the target branch. section 15.0 section 15.4.2
snow sql -f "Snowflake_objects/schemas/stg/tables/create_JSON_ORDERS_TBL_STG.sql"

This command executes a local object-creation SQL file, providing the simple baseline for development testing. section 15.4.2

snow sql -q "execute immediate from @ADMIN_DB.GIT_INTEGRATION.SF_DE/branches/main/Chapter_15/
Snowflake_objects/schemas/stg/tables/create_JSON_ORDERS_TBL_STG.sql"

This query executes a committed SQL file from a branch path in the Snowflake Git repository stage. section 15.4.2

The Visual Studio Code Snowflake extension supports interactive SQL execution during development, but it does not replace Snowflake CLI for continuous integration. Password authentication is identified as the least secure option; SSO, MFA, OAuth, and key-pair authentication are more secure alternatives, with key pairs suited to pipeline authentication. section 15.4.1 section 15.7

How Snowflake Data Engineering covers it

How deep it goes
Explains installation, connection configuration, testing, and local or staged SQL execution; defers complete command coverage to documentation.
Examples
Demonstrates help and connection-test commands, a config.toml connection, local table-creation execution, repository fetch, and staged execution.
What it assumes
Requires Python 3.8 or later, pip, and Snowflake connection details; teaches installation and default connection setup from zero.
What you can do after
Operate/configure it to test local SQL files and execute committed repository scripts against Snowflake.
How it connects
Connects continuous integration, Git repository stages, EXECUTE IMMEDIATE FROM, database change management, and key-pair authentication.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Snowflake Data Engineering. The section links point to the parts of the book it draws on.