MeltanoLabs Target Snowflake

0.18.12 · active · verified Thu Apr 16

meltanolabs-target-snowflake is a Singer target designed to load data into Snowflake, built with the Meltano SDK for Singer Targets. It facilitates data ingestion from various Singer taps into a Snowflake data warehouse. The library is actively maintained, with frequent updates aligning with the Meltano SDK's development. It is the default and recommended `target-snowflake` variant within the Meltano ecosystem.

Common errors

Warnings

Install

Imports

Quickstart

The quickest way to get started with `meltanolabs-target-snowflake` is by using the Meltano CLI. After adding the target to your Meltano project, configure it using the interactive setup which guides you through providing Snowflake connection details. Alternatively, configuration can be managed via environment variables. The `meltano invoke target-snowflake --initialize` command can help set up a new Snowflake account with necessary roles and grants.

# 1. Install Meltano (if not already installed)
# pipx install meltano

# 2. Initialize a Meltano project (if not already in one)
# meltano init my-project
# cd my-project

# 3. Add the target-snowflake loader to your project
meltano add target-snowflake

# 4. Configure Snowflake connection details (interactive setup is recommended)
meltano config target-snowflake set --interactive
# This will prompt for account, user, password, role, database, warehouse, etc.
# Alternatively, set via environment variables (e.g., TARGET_SNOWFLAKE_ACCOUNT, TARGET_SNOWFLAKE_USER)

# 5. Run an EL pipeline (example with a dummy tap)
# Replace 'tap-carbon-intensity' with your actual tap
# Ensure environment variables like SF_ACCOUNT, SF_USER, SF_PASSWORD, etc. are set if not using interactive config.
# For direct execution without Meltano, pipe JSON data:
# echo '{"type": "RECORD", "stream": "my_stream", "record": {"id": 1, "value": "test"}}' | target-snowflake --config config.json

# Example of setting environment variables for direct execution (replace with your actual credentials)
import os
os.environ['TARGET_SNOWFLAKE_ACCOUNT'] = os.environ.get('SNOWFLAKE_ACCOUNT', 'your_account_identifier')
os.environ['TARGET_SNOWFLAKE_USER'] = os.environ.get('SNOWFLAKE_USER', 'your_snowflake_user')
os.environ['TARGET_SNOWFLAKE_PASSWORD'] = os.environ.get('SNOWFLAKE_PASSWORD', 'your_snowflake_password')
os.environ['TARGET_SNOWFLAKE_DATABASE'] = os.environ.get('SNOWFLAKE_DATABASE', 'your_database')
os.environ['TARGET_SNOWFLAKE_WAREHOUSE'] = os.environ.get('SNOWFLAKE_WAREHOUSE', 'your_warehouse')
os.environ['TARGET_SNOWFLAKE_ROLE'] = os.environ.get('SNOWFLAKE_ROLE', 'your_role')

# To run an EL pipeline with Meltano (assuming 'tap-carbon-intensity' is added):
# meltano install # ensure plugins are installed
# meltano run tap-carbon-intensity target-snowflake

# Interactive Snowflake account initialization (requires SYSADMIN credentials)
# meltano invoke target-snowflake --initialize

view raw JSON →