Snowflake SQLAlchemy Dialect providing comprehensive database connectivity and ORM support for Snowflake cloud data warehouse
npx @tessl/cli install tessl/pypi-snowflake-sqlalchemy@1.7.0A comprehensive SQLAlchemy dialect that enables developers to connect and interact with Snowflake databases using SQLAlchemy's Object-Relational Mapping (ORM) and Core APIs. It serves as a bridge between SQLAlchemy applications and Snowflake's cloud data warehouse, offering native support for Snowflake-specific features like VARIANT/ARRAY/OBJECT data types, clustering, merge operations, key-pair authentication, and advanced table types.
pip install snowflake-sqlalchemyimport snowflake.sqlalchemy
from snowflake.sqlalchemy import VARIANT, ARRAY, OBJECT
from snowflake.sqlalchemy import HybridTable, DynamicTable, IcebergTable
from snowflake.sqlalchemy import MergeInto, CopyIntoStoragefrom sqlalchemy import create_engine, Column, Integer, String, MetaData, Table
from snowflake.sqlalchemy import VARIANT, TEXT
# Create connection to Snowflake
engine = create_engine(
'snowflake://user:password@account_identifier/database/schema',
echo=True
)
# Define table with Snowflake-specific types
metadata = MetaData()
user_table = Table(
'users',
metadata,
Column('id', Integer, primary_key=True),
Column('name', TEXT()),
Column('profile', VARIANT)
)
# Create table
metadata.create_all(engine)
# Insert data with semi-structured content
with engine.connect() as conn:
conn.execute(
user_table.insert(),
{'id': 1, 'name': 'John', 'profile': '{"age": 30, "city": "NYC"}'}
)The Snowflake SQLAlchemy dialect extends SQLAlchemy's type system and operations to support Snowflake's unique features:
snowflake:// connection strings)Comprehensive type system supporting both standard SQL types and Snowflake's semi-structured data types including VARIANT, ARRAY, OBJECT, and MAP with full type safety.
# Standard SQL types (re-exported from SQLAlchemy)
from snowflake.sqlalchemy import (
BIGINT, BINARY, BOOLEAN, CHAR, DATE, DATETIME, DECIMAL,
FLOAT, INTEGER, REAL, SMALLINT, TIME, TIMESTAMP, VARCHAR
)
# Snowflake-specific types
from snowflake.sqlalchemy import (
VARIANT, ARRAY, OBJECT, MAP,
TIMESTAMP_TZ, TIMESTAMP_LTZ, TIMESTAMP_NTZ,
GEOGRAPHY, GEOMETRY
)Advanced table types for modern data architectures including hybrid OLTP tables, dynamic tables for streaming analytics, and Iceberg tables for data lake integration.
from snowflake.sqlalchemy import (
SnowflakeTable, HybridTable, DynamicTable, IcebergTable
)Specialized SQL operations including MERGE statements for upserts and COPY INTO commands for bulk data loading from cloud storage with comprehensive formatting options.
from snowflake.sqlalchemy import (
MergeInto, CopyIntoStorage,
CSVFormatter, JSONFormatter, PARQUETFormatter
)Native integration with AWS S3 and Azure Blob Storage including credential management, encryption support, and stage management for external data access.
from snowflake.sqlalchemy import (
AWSBucket, AzureContainer, ExternalStage,
CreateStage, CreateFileFormat
)Connection management, URL building utilities, and configuration options for optimizing Snowflake database connectivity within SQLAlchemy applications.
from snowflake.sqlalchemy import URL
from snowflake.sqlalchemy.util import (
parse_url_boolean, parse_url_integer
)