Skip to content
Get Started for Free

Local Development

This guide walks you through starting the Snowflake emulator, connecting the Snowflake CLI, and running your first SQL query. You will perform the entire workflow on your local machine without a Snowflake account or consuming Snowflake credits.

A successful walkthrough results in:

  • A running emulator: A local, Snowflake-compatible endpoint.
  • A Snowflake CLI connection: A localstack connection profile pointed at your local emulator.
  • Sample data: A database, schema, and table populated with sample records via a CSV upload.

If you haven’t installed LocalStack yet, follow the installation guide to get started.

Step 1: Install and start the Snowflake emulator

Section titled “Step 1: Install and start the Snowflake emulator”

Start the Snowflake emulator:

Terminal window
lstk start --type snowflake

The first run triggers a browser-based authentication flow. After authentication, lstk pulls the LocalStack for Snowflake image and initializes the container, then prints a confirmation banner once the emulator is ready.

Create a connection profile that points the Snowflake CLI at your local emulator:

Terminal window
snow connection add \
--connection-name localstack \
--user test \
--password test \
--account test \
--host snowflake.localhost.localstack.cloud

You might be prompted for additional optional parameters, such as the connection port, database name, or warehouse name. These can be skipped.

Test the connection:

Terminal window
snow connection test --connection localstack
Output
+--------------------------------------------------------+
| key | value |
|-----------------+--------------------------------------|
| Connection name | localstack |
| Status | OK |
| Host | snowflake.localhost.localstack.cloud |
| Account | test |
| User | test |
+--------------------------------------------------------+

A Status of OK confirms the Snowflake CLI can reach your local emulator.

Open an interactive SQL session using the localstack connection profile:

Terminal window
snow sql --connection localstack

In this session, we’ll create a student records database that demonstrates how to create databases, schemas, and tables, upload data using a stage, and query the results.

Create the database and use it:

CREATE DATABASE IF NOT EXISTS STUDENT_RECORDS_DEMO;
USE DATABASE STUDENT_RECORDS_DEMO;
Output
+-----------------------------------------------------+
| status |
|-----------------------------------------------------|
| Database STUDENT_RECORDS_DEMO successfully created. |
+-----------------------------------------------------+

Create a schema and use it:

CREATE SCHEMA IF NOT EXISTS PUBLIC;
USE SCHEMA PUBLIC;

Create the STUDENT_DATA table:

CREATE OR REPLACE TABLE STUDENT_DATA (
student_id VARCHAR(50),
first_name VARCHAR(100),
last_name VARCHAR(100),
email VARCHAR(200),
enrollment_date DATE,
gpa FLOAT,
major VARCHAR(100)
);
Output
+------------------------------------------+
| status |
|------------------------------------------|
| Table STUDENT_DATA successfully created. |
+------------------------------------------+

Create a file format and a stage for uploading files:

CREATE OR REPLACE FILE FORMAT csv_format
TYPE = CSV
FIELD_DELIMITER = ','
SKIP_HEADER = 1
NULL_IF = ('NULL', 'null')
EMPTY_FIELD_AS_NULL = TRUE;
CREATE OR REPLACE STAGE student_data_stage
FILE_FORMAT = csv_format;

Exit the SQL session (!exit or Ctrl+D), and create a student_data.csv file with sample records:

student_id,first_name,last_name,email,enrollment_date,gpa,major
S001,John,Smith,john.smith@university.edu,2023-08-15,3.75,Computer Science
S002,Alice,Johnson,alice.johnson@university.edu,2023-08-15,3.92,Mathematics
S003,Bob,Williams,bob.williams@university.edu,2022-08-15,3.45,Engineering
S004,Carol,Brown,carol.brown@university.edu,2024-01-10,3.88,Physics
S005,David,Davis,david.davis@university.edu,2023-08-15,2.95,Biology

Upload the CSV file to the stage:

Terminal window
snow sql --connection localstack \
--query "PUT file://student_data.csv @student_data_stage AUTO_COMPRESS=TRUE;"
Output
source |target |source_size|target_size|source_compression|target_compression|status |message|
----------------+-------------------+-----------+-----------+------------------+------------------+--------+-------+
student_data.csv|student_data.csv.gz| 425| 262|NONE |GZIP |UPLOADED| |

Load the data from the stage into the table, then query it:

Terminal window
snow sql --connection localstack --query "
COPY INTO STUDENT_DATA FROM @student_data_stage ON_ERROR = 'CONTINUE';
SELECT COUNT(*) AS total_students FROM STUDENT_DATA;
"
Output
+----------------+
| TOTAL_STUDENTS |
|----------------|
| 5 |
+----------------+

The Snowflake CLI executed every statement against the locally emulated Snowflake instance. Because no actual Snowflake resources are created, you won’t consume any real Snowflake credits.

View the state of your local database via the LocalStack Web Application. Navigate to the Snowflake tab to inspect your running resources using the SQL Worksheet, which provides syntax highlighting, autocomplete, and a resource tree for your databases, schemas, and tables.

Running SQL queries using LocalStack Web Application

For more on the Web Application’s Snowflake tooling, see User Interface.

Stop your LocalStack container to remove all emulated resources. LocalStack is ephemeral by default; stopping the instance clears the state.

Terminal window
lstk stop

To persist your database, schema, and table data across restarts, see State Management.

Remove the local file you created in this guide:

Terminal window
rm student_data.csv
  • Load data from cloud storage: Use Storage Integrations (currently supporting AWS S3) or a script (see Snowflake Drivers).
  • Automate data ingestion: Configure Snowpipe for automated data ingestion from external sources.
  • Use your favorite tools: Continue developing against LocalStack for Snowflake with your preferred integrations.

You have successfully connected the Snowflake CLI and run your first query against a local Snowflake-compatible emulator. Proceed to the CI/CD guide to learn how to integrate LocalStack for Snowflake into your automated continuous integration pipelines.

Was this page helpful?