Edits history of script submission #22533 for ' Execute Query & Return Results (snowflake)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    import type { Sql } from "windmill-client@1";
    
    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 hugo989 3 days ago