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

@db2lake/driver-snowflake

v0.2.0

Published

Snowflake destination driver for db2lake

Readme

@db2lake/driver-snowflake

This is a destination driver for Snowflake, part of the @db2lake framework. The driver provides functionality to connect to and write data to Snowflake databases using the official snowflake-sdk package.

Features

  • Bulk data loading with configurable batch sizes
  • Automatic table creation with custom schema support
  • Transaction management with configurable timeouts
  • Clustering and data retention configuration
  • Connection management and resource cleanup
  • Error handling with configurable retries
  • Support for various authentication methods

Installation

Install the package from your workspace or npm registry using the package name declared in package.json:

npm install @db2lake/driver-snowflake

Usage

import { SnowflakeDestinationDriver } from '@db2lake/driver-snowflake';

interface UserRecord {
  id: number;
  name: string;
  created_at: Date;
}

const config = {
  connection: {
    account: 'your_account.region.cloud',
    username: 'your_username',
    password: 'your_password',
    database: 'your_database',
    warehouse: 'your_warehouse',
    schema: 'PUBLIC',
    role: 'ACCOUNTADMIN'
  },
  table: {
    schema: 'PUBLIC',
    table: 'users',
    createIfNotExists: true,
    columns: [
      { name: 'id', type: 'NUMBER', primaryKey: true },
      { name: 'name', type: 'VARCHAR', nullable: false },
      { name: 'created_at', type: 'TIMESTAMP_NTZ' }
    ],
    clusterBy: ['created_at'],
    retentionDays: 90
  },
  batch: {
    size: 1000,
    maxRetries: 3,
    retryDelay: 1000
  },
  transaction: {
    // Note: the driver checks `transaction?.enabled`. If omitted or false, the driver
    // will perform non-transactional inserts. Enable when you want BEGIN/COMMIT semantics.
    enabled: true,
    queryTimeout: 60,
    maxParallelStatements: 4
  }
};

async function example() {
  const driver = new SnowflakeDestinationDriver<UserRecord>(config);
  
  try {
    await driver.connect();
    
    const records: UserRecord[] = [
      { id: 1, name: 'John Doe', created_at: new Date() },
      { id: 2, name: 'Jane Smith', created_at: new Date() }
    ];
    
    await driver.insert(records);
  } finally {
    await driver.close();
  }
}

Configuration

Connection Options

| Option | Type | Required | Description | |--------|------|----------|-------------| | account | string | Yes | Account identifier (<account>.<region>.<cloud>) | | username | string | Yes | Username for authentication | | password | string | Yes | Password for authentication | | database | string | Yes | Database name | | warehouse | string | Yes | Warehouse to use | | schema | string | No | Schema name (default: PUBLIC) | | role | string | No | Role to use (default: ACCOUNTADMIN) | | authenticator | string | No | Authentication type (default: SNOWFLAKE) |

Table Options

| Option | Type | Required | Description | |--------|------|----------|-------------| | schema | string | No (default: PUBLIC) | Schema name | | table | string | Yes | Table name | | createIfNotExists | boolean | No | Create table if missing | | columns | SnowflakeColumn[] | No* | Column definitions (*required if createIfNotExists=true) | | clusterBy | string[] | No | Clustering keys | | retentionDays | number | No | Data retention period |

Column Definition

| Option | Type | Description | |--------|------|-------------| | name | string | Column name | | type | string | Snowflake data type | | nullable | boolean | Allow NULL values | | default | string | Default value | | unique | boolean | Unique constraint | | primaryKey | boolean | Primary key constraint |

Batch Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | size | number | 1000 | Rows per batch | | maxRetries | number | 3 | Max retry attempts | | retryDelay | number | 1000 | Delay between retries (ms) |

Transaction Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | enabled | boolean | false | Enable transactions (driver will only BEGIN/COMMIT when true) | | queryTimeout | number | - | Query timeout (seconds) | | maxParallelStatements | number | 1 | Max parallel statements |

Error Handling

The driver implements comprehensive error handling:

  • Connection errors with detailed messages
  • Automatic transaction rollback on errors
  • Configurable retry mechanism for transient failures
  • Proper resource cleanup in all scenarios

License

This project is licensed under the MIT License - see the LICENSE file for details.