Published in


Connect to Snowflake with Node.js Driver

This will be the first entry into my Snowflake toolbox. Today I am going to set my MacBook Pro up to connect to a Snowflake data warehouse via the Snowflake Node.js driver. This could come in handy when needing to move data between systems where direct connections are not available and you need an intermediary. Let’s get started.

This tutorial does require you to have access to a Snowflake data warehouse. If you don’t, you can sign up for a free trial account.

Install Homebrew. I prefer using this method to manage software packages. You can find everything you need on their page, or you can copy and paste:

/usr/bin/ruby -e "$(curl -fsSL"

which will get you going right away.

Once Homebrew is installed, you can use it to install any version of Node.js you need. For this example, I decided on v6.14.2 . This version allowed me to maintain some compatibility with other things I plan to use Node for.

Install Node.js v6.14.2. At the command prompt enter the following:

$ brew install node@6

This will install the version 6 of Node.js . You can verify this after the install by checking the version with the following command:

$ node -v

Install the snowflake-sdk. With Node installed, you can now use the Node Package Manager (npm) to download and install the snowflake driver.

$ npm install snowflake-sdk

Verify the driver has been installed by confirming the snowflake-sdk subdirectory exists within the node_modules directory.

If things have been successful thus far, we are ready to connect to the Snowflake cloud data warehouse instance via Node.js.

Create a directory

$ mkdir -p snowflake_dev
$ cd snowflake_dev

In this directory, create a file (sfcon.js) by copying and pasting the text below. Remember to use your credentials for account, username, password, and region.

var snowflake = require('snowflake-sdk');
var connection = snowflake.createConnection({
account: 'account',
username: 'username',
password: 'password',
region: 'region'
connection.connect(function(err, conn) {
if (err) {
console.error('Unable to connect: ' + err.message);
} else {
console.log('Successfully connected as id: ' + connection.getId());

You can find detailed information on these parameter values and others in the official Snowflake Documentation for the Node.js driver.

If you have successfully configured everything, simply run the sfcon.js file using node.

$ node sfcon.js
Successfully connected as id: <connection id>

Look for more posts from me on #SnowflakeDB


dbaontap Snowflake

Originally published at dbaonTap.



Snowflake articles from engineers using Snowflake to power their data.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Danny Bryant

Danny Bryant

Principal Solution Architect — Snowflake | Oracle ACE (Alumni)| Speaker | SCUBA Diver | Martial Artist |