1.0.2 • Published 3 years ago

snowflake-pool v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

snowflake-pool

A Promise-based connection pool for your Snowflake data warehouse.

This is a simple wrapper that enables pooling of Snowflake SDK connections. In addition, this wrapper makes use of the snowflake-promise API which provides a Promise-based API instead of the core callback-based API.

Installation

  • npm i snowflake-pool

Basic usage

const connectionPool = createSnowflakePool({
  account: '<account name>',
  username: '<username>',
  password: '<password>',
  database: 'SNOWFLAKE_SAMPLE_DATA',
  schema: 'SOLUTIONSFIT_TEST',
  warehouse: 'DEMO'
});

await connectionPool.use(async (client) => {
  const rows = await client.execute(
    'SELECT COUNT(*) FROM USERS WHERE FIRSTNAME=:1',
    ['John']
  );

  console.log(rows);
});

Usage with Pooling Configuration

const connectionPool = createSnowflakePool({
    account: '<account name>',
    username: '<username>',
    password: '<password>',
    database: 'SNOWFLAKE_SAMPLE_DATA',
    schema: 'SOLUTIONSFIT_TEST',
    warehouse: 'DEMO'
  }, {
    max: 10,
    min: 0,
    autostart: false,
    idleTimeoutMillis: 60 * 60 * 1000,
    evictionRunIntervalMillis: 60 * 1000,
  });
}

await connectionPool.use(async (client) => {
  const rows = await client.execute(
    'SELECT COUNT(*) FROM USERS WHERE FIRSTNAME=:1',
    ['John']
  );

  console.log(rows);
});

Connecting

The createSnowflakePool function takes up to four arguments:

createSnowflakePool(connectionOptions, [ poolOptions, [ loggingOptions, [ configureOptions ] ] ])