Nodejs

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:

 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:

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

 

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

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

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.

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.

Look for more posts from me on #SnowflakeDB

Enjoy!

dbaontap Snowflake

 

 


Also published on Medium.