Skip to main content

Getting Started

Installation

Install using npm, yarn, or pnpm:

npm i snowflake-promise

When you install this library, the official snowflake-sdk will be installed automatically as a peerDependency.

Quick Start

Wrap any Snowflake connection with promisifyConnection to add Promise support:

import snowflake from "snowflake-sdk";
import { promisifyConnection } from "snowflake-promise";

// Wrap any Snowflake connection to add Promise support
const connection = promisifyConnection(
snowflake.createConnection({
/* your config */
}),
);

// Now you can use async/await instead of callbacks!
await connection.connect();
const { resultsPromise } = connection.execute({ sqlText: "SELECT * FROM users" });
const results = await resultsPromise;

Executing Queries

The execute method returns an object with two properties, resultsPromise and statement. Most of the time you only need the results:

const { resultsPromise } = connection.execute({
sqlText: "SELECT * FROM YOUR_TABLE",
});

const results = await resultsPromise;
console.log(results);

The properties of the returned object are:

  • resultsPromise - await this for your query results
  • statement - use this for advanced operations like cancellation (can be ignored if you don’t need it)
tip

See the API documentation for more details.

Backward Compatibility

Backward compatibility with the callback-based Snowflake SDK

Existing callback-based code continues to work unchanged. When you pass a callback to promisified methods like connect or execute, they operate in callback mode and don’t return a Promise. This ensures full backward compatibility with existing applications.

Backward compatibility with previous versions of this library

Code written with previous versions of this library will continue to work thanks to a backwards-compatibility layer. Consider migrating to the new promisifyConnection API. See the Migration Guide for details.