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="<yourSnowflakeaccount>"user="<yourusername>"password="<yourpassword>"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
