Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Environment:TobikoData Sqlmesh Snowflake Connection

From Leeroopedia


Knowledge Sources
Domains Snowflake, Data Warehouse, Cloud
Last Updated 2026-02-07 21:00 GMT

Overview

Snowflake engine adapter connection environment enabling SQLMesh to execute transformations on Snowflake data warehouse.

Description

The Snowflake connection environment provides SQLMesh integration with Snowflake's cloud data platform. It includes the official Snowflake connector with pandas integration and secure local storage capabilities, plus Snowpark Python for advanced DataFrame operations. The adapter manages Snowflake-specific features including catalog management with SQLMESH_MANAGED comment tags and Iceberg table support.

Usage

This environment is required when using Snowflake as the execution engine for SQLMesh models, for state synchronization stored in Snowflake, or when running engine-specific tests against Snowflake. Configure connection details through SnowflakeConnectionConfig or environment variables.

System Requirements

Category Requirement Notes
Network Access to Snowflake account HTTPS connectivity required
Authentication Valid Snowflake credentials User/password or key-based auth
Snowflake Account Active account with warehouse Warehouse must be running
Database Existing database Must have CREATE SCHEMA permissions

Dependencies

System Packages

  • OpenSSL libraries (for cryptography package)
  • System CA certificates

Python Packages

  • cryptography<46.0.0 - Cryptographic operations for secure connections
  • snowflake-connector-python[pandas,secure-local-storage] - Official Snowflake connector with pandas and secure storage
  • snowflake-snowpark-python - Snowpark DataFrame API

Credentials

Required environment variables for Snowflake connection:

  • SNOWFLAKE_ACCOUNT - Snowflake account identifier (e.g., xy12345.us-east-1)
  • SNOWFLAKE_WAREHOUSE - Warehouse name for query execution
  • SNOWFLAKE_DATABASE - Database name for SQLMesh operations
  • SNOWFLAKE_USER - Username for authentication
  • SNOWFLAKE_PASSWORD - Password for authentication

Optional configuration:

  • SNOWFLAKE_ROLE - Role to assume after connection
  • SNOWFLAKE_SCHEMA - Default schema name
  • SNOWFLAKE_AUTHENTICATOR - Authentication method (default: snowflake)

Quick Install

# Install SQLMesh with Snowflake support
pip install "sqlmesh[snowflake]"

# Set environment variables
export SNOWFLAKE_ACCOUNT="your_account"
export SNOWFLAKE_WAREHOUSE="your_warehouse"
export SNOWFLAKE_DATABASE="your_database"
export SNOWFLAKE_USER="your_user"
export SNOWFLAKE_PASSWORD="your_password"

# Or configure in config.yaml
cat > config.yaml << EOF
gateways:
  snowflake:
    connection:
      type: snowflake
      account: your_account
      warehouse: your_warehouse
      database: your_database
      user: your_user
      password: your_password
EOF

Code Evidence

# File: pyproject.toml:122-126
snowflake = [
    "cryptography<46.0.0",
    "snowflake-connector-python[pandas,secure-local-storage]",
    "snowflake-snowpark-python",
]
# File: sqlmesh/core/engine_adapter/snowflake.py:161
# Snowflake adapter manages catalogs with SQLMESH_MANAGED comment tag
def _create_catalog_if_not_exists(
    self,
    catalog_name: str,
    properties: t.Dict[str, exp.Expression] = None,
) -> None:
    """Creates a catalog (database) if it doesn't exist with SQLMESH_MANAGED tag."""
    properties = properties or {}
    properties[exp.Properties.COMMENT] = exp.Literal.string("SQLMESH_MANAGED")
    # ... implementation
# File: sqlmesh/core/config/connection.py (SnowflakeConnectionConfig class)
class SnowflakeConnectionConfig(ConnectionConfig):
    """Configuration for Snowflake connections."""
    account: str
    warehouse: str
    database: str
    user: str
    password: t.Optional[str] = None
    role: t.Optional[str] = None
    authenticator: t.Optional[str] = None
    # ... additional fields

Common Errors

Error Message Cause Solution
250001: Could not connect to Snowflake backend Invalid account identifier or network issue Verify SNOWFLAKE_ACCOUNT format (include region if needed)
390114: Authentication token expired Session expired or invalid credentials Re-authenticate with fresh credentials
002003: Database does not exist Target database not found Create database or verify SNOWFLAKE_DATABASE value
090105: Cannot perform CREATE SCHEMA Insufficient permissions Grant CREATE SCHEMA privilege to user/role
cryptography version conflict cryptography >= 46.0.0 installed Pin to cryptography<46.0.0

Compatibility Notes

  • Cryptography package must be < 46.0.0 due to breaking changes
  • Supports both Snowflake native tables and Iceberg tables
  • SQLMESH_MANAGED comment tag used to identify SQLMesh-created catalogs
  • Warehouse must be active during operations (costs apply)
  • Multi-cluster warehouses supported for parallel execution
  • Supports Snowflake's TRANSIENT tables for temporary data
  • Role-based access control (RBAC) fully supported
  • Key-pair authentication supported as alternative to password

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment