# snowflake-pool

> Snowflake connection pool

Latest version **1.0.2** (published 2021-07-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install snowflake-pool
pnpm add snowflake-pool
yarn add snowflake-pool
bun add snowflake-pool
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-07-07 |
| First published | 2021-06-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 20.2 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Jacob Orshalick |
| Maintainers | jorshali |
| Keywords | snowflake, connection, pool, promise |

## Links

- npm: https://www.npmjs.com/package/snowflake-pool
- Homepage: https://github.com/jorshali/snowflake-pool
- Issues: https://github.com/jorshali/snowflake-pool/issues
- npm.io page: https://npm.io/package/snowflake-pool

## Dependencies (3)

- [generic-pool](https://npm.io/package/generic-pool.md) ^3.7.8
- [snowflake-sdk](https://npm.io/package/snowflake-sdk.md) ^1.6.1
- [snowflake-promise](https://npm.io/package/snowflake-promise.md) ^4.5.0

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2021-07-07
- 1.0.1 — 2021-06-15
- 1.0.0 — 2021-06-15

## README

# snowflake-pool

A Promise-based connection pool for your [Snowflake](https://www.snowflake.net/) data warehouse.

This is a simple wrapper that enables pooling of [Snowflake SDK](https://www.npmjs.com/package/snowflake-sdk) connections.  In addition, this wrapper makes use of the [snowflake-promise](https://www.npmjs.com/package/snowflake-promise) API which provides a Promise-based API instead of the core callback-based API.

## Installation

* `npm i snowflake-pool`

## Basic usage

```typescript
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

```typescript
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 ] ] ])`

* `connectionOptions`
  * Supported options are here: <https://docs.snowflake.net/manuals/user-guide/nodejs-driver-use.html#required-connection-options>
* `poolOptions`
  * Most supported options are found here under ops: <https://www.npmjs.com/package/generic-pool>, with the addition of,
  * `validate` (optional, function): If provided will call this function to validate a connection.
* `loggingOptions`
  * Most supported options are found here under ops: <https://www.npmjs.com/package/snowflake-promise#connecting>, with the addition of:
  * `logConnection` (optional, function): If provided, this function will be called to log connection pooling status messages. For example, set `logConnection` to `console.log` to log all connection pooling status messages to the console.
* `configureOptions`
  * Supported options are here: <https://www.npmjs.com/package/snowflake-promise#connecting>

---
_Source: https://npm.io/package/snowflake-pool · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
