Snowflake

Overview

The Snowflake connector enables your Leena AI Agents to integrate with your organization's Snowflake data warehouse, facilitating automated SQL query execution, data insertion, and data warehouse operations.

Snowflake is a cloud-based data warehousing platform that provides scalable storage and compute resources for analytics and data processing. The Snowflake connector allows Leena AI to automate data warehouse workflows, execute queries, and manage data operations seamlessly.

API Details

Leena AI integrates with Snowflake via the Snowflake Node.js Driver.

Documentation link: https://docs.snowflake.com/en/developer-guide/node-js/nodejs-driver

Setup

The Snowflake connector supports two authentication methods: Username & Password authentication and Key Pair (JWT) authentication.

Prerequisites

Before setting up the Snowflake connector, ensure you have:

  • Access to a Snowflake account
  • Administrator or user creation privileges in Snowflake
  • Access to your Leena AI workspace with connector management permissions
  • For Key Pair authentication: ability to generate and manage RSA key pairs

Authentication Methods

Method 1: Username & Password Authentication

This method uses standard password-based authentication with Snowflake credentials.

Get credentials

Here is how to create a user with password:

  1. Log in to Snowflake web interface
  2. Click on User Profile in bottom left → Account → View Account Details
  3. Note the Account Identifier
  4. Switch to ACCOUNTADMIN or USERADMIN role
  5. Navigate to Governance & Security
  6. Click on Create User from top-right
  7. Fill in the form with username and password
  8. Click Create User (Remember the Username and Password)
  9. Use the Account Identifier, Username, and Password for creating the connector

Add connection

Here is how to add a connection on Leena AI:

  1. Log in to your Leena AI workspace
  2. Navigate to Settings > Integrations
  3. Search for "Snowflake" and select it from the list to add its new connector
  4. Start configuring the connector with Username & Password authentication
    1. Account: Snowflake account identifier (e.g., myorg-account_name)
    2. Username: Snowflake username
    3. Password: Account password
  5. Complete the configuration and save
  6. Test the connection to verify successful setup

Method 2: Key Pair (JWT) Authentication

This method uses certificate-based authentication with RSA private key for enhanced security.

Get credentials

Here is how to set up Key Pair authentication:

  1. Generate RSA Key Pair
    1. Generate a private key using OpenSSL or similar tool
    2. Generate corresponding public key
    3. Convert private key to PKCS#8 format if needed
  2. Configure Snowflake User
    1. Log in to Snowflake web interface
    2. Click on User Profile in bottom left → Account → View Account Details
    3. Note the Account Identifier
    4. Execute SQL command to set public key for user:
      ALTER USER <username> SET RSA_PUBLIC_KEY='<public_key_value>';
    5. Verify the public key is set correctly
  3. For detailed instructions, refer to: Key-pair authentication and key-pair rotation

Add connection

Here is how to add a connection on Leena AI:

  1. Log in to your Leena AI workspace
  2. Navigate to Settings > Integrations
  3. Search for "Snowflake" and select it from the list to add its new connector
  4. Start configuring the connector with Key Pair authentication
    1. Account: Snowflake account identifier (e.g., myorg-account_name)
    2. Username: Snowflake username
    3. Private Key: Private key in PKCS#8 format
    4. Passphrase: Passphrase for encrypted key (if applicable)
  5. Complete the configuration and save
  6. Test the connection to verify successful setup

Actions

The following actions are supported for the Snowflake connector:

Execute Query

Executes custom SQL queries on Snowflake data warehouse including SELECT, INSERT, UPDATE, DELETE, and DDL statements. The Agent can leverage the skill (workflow), which has been designed to execute SQL queries in Snowflake, once the user raises a query to do so.

Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescription
DatabaseTarget database name in Snowflake
SchemaTarget schema name within the database
WarehouseCompute warehouse to use for query execution
RoleRole for query execution
QuerySQL query to execute

Use Cases

Use Case 1: Execute Simple SELECT Query

Retrieve data from a Snowflake table to analyze or display results.

Input Example:

{
  "database": "MY_DATABASE",
  "schema": "PUBLIC",
  "warehouse": "COMPUTE_WH",
  "role": "ACCOUNTADMIN",
  "query": "SELECT * FROM users LIMIT 10"
}

Response:

{
  "status": 200,
  "data": [
    {
      "ID": "1",
      "NAME": "John Doe",
      "EMAIL": "[email protected]",
      "CREATED_AT": "2025-01-15"
    },
    {
      "ID": "2",
      "NAME": "Jane Smith",
      "EMAIL": "[email protected]",
      "CREATED_AT": "2025-02-20"
    }
  ]
}

Use Case 2: Execute UPDATE Query

Update existing records in a Snowflake table based on specific conditions.

Input Example:

{
  "database": "MY_DATABASE",
  "schema": "PUBLIC",
  "warehouse": "COMPUTE_WH",
  "role": "ACCOUNTADMIN",
  "query": "UPDATE users SET status = 'active' WHERE last_login > DATEADD(day, -30, CURRENT_DATE())"
}

Use Case 3: Execute DDL Statement (Create Table)

Create a new table structure in Snowflake for storing data.

Input Example:

{
  "database": "MY_DATABASE",
  "schema": "PUBLIC",
  "warehouse": "COMPUTE_WH",
  "role": "ACCOUNTADMIN",
  "query": "CREATE TABLE employees (id INT, name VARCHAR(100), email VARCHAR(255), hire_date DATE)"
}

Response

Upon successful execution, the action returns:

  • Query execution status
  • Result data (for SELECT queries)
  • Number of rows affected (for INSERT, UPDATE, DELETE)
  • Execution metadata

Insert Data

Inserts single or multiple rows into a Snowflake table with automatic column detection from JSON data. The Agent can leverage the skill (workflow), which has been designed to insert data into Snowflake tables, once the user provides the data to be inserted.

Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescription
DatabaseTarget database name in Snowflake
SchemaTarget schema name within the database
WarehouseCompute warehouse to use for insert operation
RoleRole for insert operation
TableTarget table name where data will be inserted
DataArray of objects to insert

Use Cases

Use Case 1: Insert Single Row

Insert a single record into a table for individual data entry operations.

Input Example:

{
  "database": "MY_DATABASE",
  "schema": "PUBLIC",
  "warehouse": "COMPUTE_WH",
  "role": "ACCOUNTADMIN",
  "table": "users",
  "data": [
    {
      "id": 101,
      "name": "Alice Williams",
      "email": "[email protected]",
      "created_at": "2025-11-12"
    }
  ]
}

Response:

{
  "status": 200,
  "data": {
    "message": "Successfully inserted 1 row(s) into users",
    "rowsInserted": 1,
    "table": "users"
  }
}

Use Case 2: Bulk Insert Multiple Rows

Insert multiple records in a single operation for improved performance and efficiency.

Input Example:

{
  "database": "MY_DATABASE",
  "schema": "PUBLIC",
  "warehouse": "COMPUTE_WH",
  "role": "ACCOUNTADMIN",
  "table": "users",
  "data": [
    {
      "id": 201,
      "name": "John Smith",
      "email": "[email protected]",
      "department": "Engineering"
    },
    {
      "id": 202,
      "name": "Sarah Jones",
      "email": "[email protected]",
      "department": "Marketing"
    },
    {
      "id": 203,
      "name": "Mike Brown",
      "email": "[email protected]",
      "department": "Sales"
    }
  ]
}

Response:

{
  "status": 200,
  "data": {
    "message": "Successfully inserted 3 row(s) into users",
    "rowsInserted": 3,
    "table": "users"
  }
}

Response

Upon successful insertion, the action returns:

  • Insertion status
  • Number of rows inserted
  • Target table name
  • Success or error message

Error Handling

The connector provides detailed error messages for troubleshooting common issues:

Error Response Example:

{
  "status": 500,
  "data": {
    "message": "Object 'MY_DATABASE.PUBLIC.NONEXISTENT_TABLE' does not exist or not authorized."
  }
}

Common error scenarios include:

  • Table or database does not exist
  • Insufficient permissions for the specified role
  • Invalid SQL syntax
  • Connection timeout or network issues
  • Authentication failures