Search... Ctrl + K

Execute Query & Return Results (snowflake)
One script reply has been approved by the moderators Verified

Created by rossmccrann 115 days ago Used 66 times 1 Point

Execute Query and Return Results from Snowflake Statements API

No comments yet

Points: 0
deno
One script reply has been approved by the moderators
Ap­pro­ved

import type { Sql } from "https://deno.land/x/windmill@v1.31.0/mod.ts";

export async function main(token: string, account_id: string, database: string, schema: string, sql: Sql) {
  const POST_URL = `https://${account_id}.snowflakecomputing.com/api/statements`;

  const body = {
    "statement": `${sql}`,
    "timeout": 60,
    "database": `${database}`,
    "schema": `${schema}`,
  };

  const response = await fetch(POST_URL, {
    method: "POST",
    body: JSON.stringify(body),
    headers: {
      Authorization: "Bearer " + token,
      "Content-Type": "application/json",
    },
  });

  return await response.json();
}

Submitted by rossmccrann 115 days ago

Edited 115 days ago

No comments yet