npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

snowflake-multisql

v1.7.1

Published

Multi SQL Statement, Promise-based, TypeScript wrapper for Snowflake SDK

Readme

snowflake-multisql npm node GitHub issues

A Multi SQL Statement, Promise-based and Typescript version to your Snowflake data warehouse, since the original library doesn't support this multi statement calls.

Also adds nice features like:

  • replaces tags defined in the scripts by name using original data types (examples below).
  • Also replaces inline tags like select * from {%table_name%} so you can play around different scenarios between code and the sql script. Use cases: replace database name depending on the environment used (ex: db_name_dev, db_name_prod)
  • Emits progress events so you can monitor long run calls
  • Preview parsed statement before sending to Snowflake.
  • Shows duration (in miliseconds) for each chunk as well the totalDuration.
  • Shows data returned by Snowflake on each statement (and not only the last statement) with the option to ommit them as well.
  • Utils: Loads an entire folder of "*.sql" files or an array of specific files.

PS: This library works on top of the excellent Snowflake Promise for Node.js, which is a wrapper for Snowflake SDK


Installation

  • yarn add snowflake-multisql
    or
  • npm i snowflake-multisql

How to use it

The constructor extends SnowflakePromise class addin the new method executeAll. The unique method's param is deconstructed into the variables below:

{
  "sqlText": "your SQL Text string",
  "binds": "from the original library, replace tags by sequence",
  "tags": "new, replace tags by name, whatever order them appers",
  "includeResults": true,
  "preview": true
}
  • tags: replace tags by name and convert into indexed tags by the original snowflake library. You can replace tags with native objects (string, number, dates, etc). Just spread within your sql scripts like {%tag_name%} (please make sure there is no spaces around tag_name). After that, just add the array of tag/value pairs to tags param. Please check the examples below.

  • includeResults: returns field 'data' with results for each chunk.

  • preview: logs the final order of statements and parsed variables without executing them.

  • loadFiles: loads all files from a specific folder ended with ".sql" (ex: file1.sql, file2.sql)


Usage

  import { Snowflake, loadFiles } from "snowflake-multisql"

  const snowflake = new Snowflake({
    account: "<account name>",
    username: "<username>",
    password: "<password>",
    database: "DEMO_DATABASE",
    schema: "DEMO_SCHEMA",
    warehouse: "DEMO_WH",
  });

  // SWISS ARMY KNIFE: Just point your folder and this util method will
  // merge all files ended with '.sql'
  // IMPORTANT: it merges in the order files appear in your operating system
  // i.e. alphabetical order
  const sqlText = await loadFiles({
    filesPath: path.join(process.cwd(), "./sqlFolder"),
  });

  // file-1.sql content:
  //  CREATE OR REPLACE TABLE temp_table_customer as
  //  SELECT COUNT(*) FROM {%table_name%} WHERE PURCHASE_DATE={%purchase_date%};

  // file-2.sql content:
  //  SELECT * from temp_table_customer
  //  WHERE product_name = {%product_name%}

  // file-3.sql content:
  //  USE SCHEMA demo_schema;
  //  SELECT COUNT(*) FROM {%table_name%} WHERE segment_id={%segment_id%};

  const tags = [
    { tag: "purchase_date", value: new Date(1610976670682) },
    { tag: "product_name", value: "AUTOMOBILE" },
    { tag: "segment_id", value: 1234 },
    { tag: "table_name", value: "customers", inline: true },
  ];

  // NEW FEATURE: Feel free to monitor your running progress
  snowflake.progress.on("news", (data) => console.log(`
    progress: ${data.chunkOrder}/${data.chunksTotal}
    duration: ${data.duration} ms,
    totalDuration: ${data.totalDuration} ms
  `));

  const rows = await snowflake.executeAll({
    sqlText,
    tags,
    includeResults: true,
    preview: false // set it true for checking statements before sending to Snowflake.
  });

  rows.map((rows) => console.dir(rows));
}

main();

Using GENERIC types

  import { Snowflake, loadFiles } from "snowflake-multisql"

  const snowflake = new Snowflake({
    account: "<account name>",
    username: "<username>",
    password: "<password>",
    database: "DEMO_DATABASE",
    schema: "DEMO_SCHEMA",
    warehouse: "DEMO_WH",
  });

  const sqlText = await loadFiles({
    filesPath: path.join(process.cwd(), "./sqlFolder"),
  });

  type MyType = {
    id: string;
    num: number;
    date: Date;
    obj?: any;
  };

  const rows = await snowflake.executeAll<MyType>({
    sqlText,
    tags,
    includeResults: true,
  });

  rows.map((rows) => console.log("Your number is: ",rows[0].data[0].num));
}

main();

If you prefer to manage the original binds by yourself

const Snowflake = require("snowflake-multisql").Snowflake;
// or, for TypeScript:
import { Snowflake } from "snowflake-multisql";

async function main() {
  const snowflake = new Snowflake({
    account: "<account name>",
    username: "<username>",
    password: "<password>",
    database: "DEMO_DATABASE",
    schema: "DEMO_SCHEMA",
    warehouse: "DEMO_WH",
  });

  await snowflake.connect();

  const sqlText = `
    CREATE OR REPLACE TABLE temp_table_customer as
     SELECT COUNT(*) FROM customer WHERE C_MKTSEGMENT=:1;

    USE SCHEMA demo_schema;
    SELECT COUNT(*) FROM customer WHERE C_MKTSEGMENT_ID=:2;
  `;
  const binds = ["AUTOMOBILE", 1234];

  // NEW FEATURE: Feel free to monitor your running progress
  snowflake.progress.on("news", (data) =>
    console.log(`
    progress: ${data.chunkOrder}/${data.chunksTotal}
    duration: ${data.duration} ms,
    totalDuration: ${data.totalDuration} ms
  `)
  );

  const rows = await snowflake.executeAll({
    sqlText,
    binds,
    includeResults: true,
  });

  console.log(rows);
}

main();