by langgenius ยท v0.0.6
Execute SQL queries on Snowflake data warehouse (supports OAuth authentication)
This community listing does not yet include every recommended support, privacy, pricing, and permission disclosure. Review the available package permissions before installing.
Available inside your emploidai workspace after installation.
Available inside your emploidai workspace after installation.
Execute SQL queries on Snowflake data warehouse with secure OAuth 2.0 authentication.
Author: langgenius
Version: 0.0.1
Type: Tool Plugin
The Snowflake SQL plugin enables seamless integration between Dify AI applications and Snowflake data warehouse. Execute any SQL query securely using OAuth 2.0 authentication, with support for all major SQL operations including SELECT, INSERT, UPDATE, DELETE, and DDL statements.
You need a Snowflake account with appropriate permissions to create OAuth integrations. Follow these steps to set up OAuth authentication:
Run the following SQL commands in Snowflake (requires ACCOUNTADMIN role):
USE ROLE ACCOUNTADMIN;
-- Create OAuth integration
CREATE SECURITY INTEGRATION oauth_integration
TYPE = OAUTH
ENABLED = TRUE
OAUTH_CLIENT = CUSTOM
OAUTH_CLIENT_TYPE = 'CONFIDENTIAL'
OAUTH_REDIRECT_URI = 'https://your-dify-instance.com/oauth/callback'
OAUTH_ISSUE_REFRESH_TOKENS = TRUE
OAUTH_REFRESH_TOKEN_VALIDITY = 7776000 -- 90 days
BLOCKED_ROLES_LIST = ('ACCOUNTADMIN', 'SECURITYADMIN');
-- Get Client ID
DESC SECURITY INTEGRATION oauth_integration;
-- Get Client Secret
SELECT SYSTEM$SHOW_OAUTH_CLIENT_SECRETS('OAUTH_INTEGRATION');
Copy the OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET values - you'll need these for plugin configuration.
-- Create a role for the integration (recommended)
CREATE ROLE IF NOT EXISTS oauth_service_role;
-- Grant warehouse usage
GRANT USAGE ON WAREHOUSE COMPUTE_WH TO ROLE oauth_service_role;
-- Grant database and schema access
GRANT USAGE ON DATABASE YOUR_DATABASE TO ROLE oauth_service_role;
GRANT USAGE ON SCHEMA YOUR_DATABASE.PUBLIC TO ROLE oauth_service_role;
-- Grant table permissions
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES
IN SCHEMA YOUR_DATABASE.PUBLIC TO ROLE oauth_service_role;
-- Grant integration usage
GRANT USAGE ON INTEGRATION oauth_integration TO ROLE oauth_service_role;
-- Assign role to your user
GRANT ROLE oauth_service_role TO USER your_username;
After installation, configure the following OAuth parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| Account Name | Text | Yes | Your Snowflake account identifier (e.g., xy12345.us-east-1) |
| OAuth Client ID | Secret | Yes | Client ID from SYSTEM$SHOW_OAUTH_CLIENT_SECRETS |
| OAuth Client Secret | Secret | Yes | Client Secret from SYSTEM$SHOW_OAUTH_CLIENT_SECRETS |
| OAuth Scope | Text | No | Optional OAuth scope (e.g., session:role:oauth_service_role) |
The OAuth token is automatically managed and refreshed by the plugin.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| SQL Query | String | Yes | - | The SQL statement to execute |
| SQL Type | Select | Yes | SELECT | Type of SQL operation |
| Warehouse | String | No | COMPUTE_WH | Snowflake warehouse name |
| Database | String | No | - | Target database |
| Schema | String | No | PUBLIC | Target schema |
| Max Rows | Number | No | 100 | Maximum rows to return (SELECT only) |
Select the appropriate SQL type for your query:
๐ก Tip: Always specify the correct SQL type, especially for queries with WITH clauses, as they can be used with INSERT, UPDATE, or DELETE operations.
Input:
sql_query: |
SELECT
customer_id,
customer_name,
email,
total_purchases
FROM customers
WHERE total_purchases > 1000
ORDER BY total_purchases DESC
LIMIT 20
sql_type: SELECT
max_rows: 20
Output:
โ
SELECT Results (20 rows, 0.234s)
| customer_id | customer_name | email | total_purchases |
| --- | --- | --- | --- |
| C001 | Acme Corporation | contact@acme.com | 15420.50 |
| C002 | TechStart Inc | info@techstart.io | 12350.00 |
Input:
sql_query: |
INSERT INTO orders (order_id, customer_id, amount, status, created_at)
VALUES ('ORD-2025-001', 'C001', 2499.99, 'pending', CURRENT_TIMESTAMP())
sql_type: INSERT
Output:
โ
INSERT executed successfully
๐ Affected rows: 1
โฑ๏ธ Execution time: 0.145s
Input:
sql_query: |
WITH monthly_revenue AS (
SELECT
DATE_TRUNC('month', order_date) as month,
SUM(amount) as revenue
FROM orders
WHERE order_date >= DATEADD(month, -12, CURRENT_DATE())
GROUP BY 1
)
SELECT month, revenue
FROM monthly_revenue
ORDER BY month DESC
sql_type: SELECT
max_rows: 12
Use with Dify Agent to create an intelligent data analyst that can query your database and explain results in natural language.
Create workflows that generate daily/weekly reports by querying Snowflake and formatting results.
Build chatbots that can look up customer information, order status, and other data in real-time.
All queries return structured JSON data:
{
"success": true,
"sql_type": "SELECT",
"columns": ["customer_id", "customer_name"],
"rows": [{"customer_id": "C001", "customer_name": "Acme Corp"}],
"row_count": 1,
"executed_sql": "SELECT ...",
"execution_time": 0.234
}
LIMIT clauses to reduce data transfermax_rows parameterSELECT * on large tablesError: "OAuth authentication required"
Solution: Reconnect OAuth in plugin settings.
Error: "SQL compilation error: Object does not exist"
Solution: Verify database, schema, and table names. Check permissions.
Error: "Insufficient privileges to operate on table"
Solution: Grant necessary permissions to your OAuth role.
snowflake_sql/
โโโ manifest.yaml # Plugin metadata
โโโ pyproject.toml # Project metadata and direct dependencies
โโโ uv.lock # Locked dependency set
โโโ main.py # Entry point
โโโ README.md # Documentation
โโโ provider/
โ โโโ snowflake_sql.py # OAuth provider implementation
โ โโโ snowflake_sql.yaml # Provider configuration
โโโ tools/
โโโ snowflake_sql.py # Tool implementation
โโโ snowflake_sql.yaml # Tool definition
# Install dependencies
uv sync
# Run the plugin locally
python main.py
Provider (provider/snowflake_sql.py):
Tool (tools/snowflake_sql.py):
Apache License 2.0
This plugin uses the following open-source libraries: