Snowflake

This guide walks you through how to create a new connection to a Snowflake account

The Snowflake Node allows you to interact with a Snowflake database—either by querying data or inserting new records.


Connecting to Snowflake — API Key

Click the node to open its settings, then select New connection.

Enter the required connection details into the form according to the table and notes below:

Field
Value

Connection Name

This is whatever you want to name the connection

User

Your chosen Snowflake account username

Password (Optional)

Your chosen Snowflake account password

Private Key (Optional)

Only if using key-pair authentication

Account

nqxzcwd-ab12345 (see where to find below)

Warehouse

DUMMY_WAREHOUSE (see where to find below)

Role

ACCOUNTADMIN (see where to find below)

Database

DUMMY_DB (see where to find below)

Schema

DUMMY_SCHEMA (see where to find below)

Note: You need to enter at least one of the two optional fields

Account

This is your account identifier. Find it here:

Warehouse

Find it here:

Role

Find it here:

Database

Find it here:

Schema

Find it here:

Connecting to Snowflake — OAuth2

For your organization's users to connect to Snowflake using OAuth2, you must first create an OAuth2 App inside Snowflake. Once this app is created, users can use it to sign-into Snowflake via OAuth2 in third-party applications.

To create the OAuth2 App, first have someone with the ACCOUNTADMIN role run the following script in Snowflake:

CREATE OR REPLACE SECURITY INTEGRATION STACKAI_OAUTH_APP
  TYPE = OAUTH
  ENABLED = TRUE
  OAUTH_CLIENT = CUSTOM
  OAUTH_CLIENT_TYPE = 'CONFIDENTIAL'
  OAUTH_REDIRECT_URI = 'https://stack-ai.com/auth'
  OAUTH_ISSUE_REFRESH_TOKENS = TRUE
  OAUTH_REFRESH_TOKEN_VALIDITY = 7776000  -- ~90 days
  BLOCKED_ROLES_LIST = ('SYSADMIN');      -- optional: prevent high-privilege roles
;

Once the integration has been created, run the following to get a client_id and client_secret:

SELECT SYSTEM$SHOW_OAUTH_CLIENT_SECRETS('STACKAI_OAUTH_APP');

Store this information as you will need it to make an OAuth2 connection.

Establishing the connection in StackAI

When entering the new connection dialog, select Snowflake, then OAuth2:

Here, you will be prompted to enter your client_id and client_secret for your integration. Then, you will be taken to a dialog to sign in to your Snowflake user account.

Available Actions

1. Query a Snowflake Database (database_query_snowflake)

  • Description: Run queries against your Snowflake database and retrieve results.

  • Inputs:

    • sql_schema (array of strings, required): The schema of your database (tables, columns, types, etc.). Example:

      TABLE MyTable (Name TEXT, Email TEXT, Weight REAL, Height REAL);
    • query (string, required): The query you want to run. This can be in plain English or SQL. Example:

      • "What is the total revenue for the year 2024?"

      • "Show me the top 10 customers by revenue"

      • "SELECT * FROM MyTable WHERE Name = 'John'"

  • Outputs:

    • sql_query (string): The SQL query that was executed.

    • results (array of objects): The results of the query.

2. Insert Data into Snowflake (database_insert_snowflake)

  • Description: Insert new records into a table in your Snowflake database.

  • Inputs:

    • table_name (string, required): The name of the table where you want to insert data.

    • data (object/dictionary, required): The data to insert, as key-value pairs where keys are column names and values are the data. Example:

      {
        "name": "John Doe",
        "email": "[email protected]",
        "age": 30,
        "is_active": true
      }
  • Outputs:

    • sql_query (string): The INSERT SQL query that was executed.

    • rows_affected (integer): Number of rows affected by the insert.

    • success (boolean): Whether the insert was successful.


Summary Table

Action Name
Description
Key Inputs
Key Outputs

Query Snowflake Database

Run queries and get results

sql_schema, query

sql_query, results

Insert Data into Snowflake

Insert new records into a table

table_name, data

sql_query, rows_affected, success

Last updated

Was this helpful?