Snowflake - how to connect to Snowflake using NodeJS

nodejs snowflake-sdk
python access snowflake
nodejs snowflake id
snowflake sdk python
golang connect to snowflake
c# snowflake connection string
how to load data into snowflake using python
snowflake jdbc connection timeout

Does anyone has a working code to connect NodeJS and Snowflake.

Tried following instructions for NodeJS:

var snowflake = require('snowflake-sdk');

var connection = snowflake.createConnection({
  account: 'account1',
  username: 'user1',
  password: 'pass1',
  region: 'us-east-1'
});

connection.connect(function(err, conn) {
  if (err) {
    console.error('Unable to connect: ' + err.message);
  } else {
    console.log('Successfully connected as id: ' + connection.getId());
  }
});

Keep getting errors:

Network error. Could not reach Snowflake.

Similarly - following instructions for Python works without problem (using EXACT same user/pass/account etc. as for NodeJS):

import snowflake.connector

ctx = snowflake.connector.connect(
    user='user1', 
    password='pass1',
    account='account1'
)

print ("SELECT current_version():")
cs = ctx.cursor()
try:
    cs.execute("SELECT current_version()")
    one = cs.fetchone()
    print(one[0])  # 2.50.2
finally:
    cs.close()

The account that use in python has "account_id.region" something like

ctx = snowflake.connector.connect(
user='user1', 
password='pass1',
account='abc.us-east-1'
)

For node.js you need to give the same as:

var connection = snowflake.createConnection({
  account: 'abc',
  username: 'user1',
  password: 'pass1',
  region: 'us-east-1'
});

Using the Node.js Driver, The typical workflow for using the driver is: Establish a connection with Snowflake​. Execute statements, e.g. queries and DDL/DML commands. Consume the  It’s About Community: Snowflake and Node.js via an Azure Function. Snowflake is the leading cloud-based data warehouse on the market; it provides a variety of approaches and tools to acquire and transform data, but I have not seen an example of an implementation using a Node.js driver. I did, however, work with a development team at a client

Based strictly on code provided, the functional difference between the 2 examples is that the Node.js one specifies the us-east-1 region, and the Python one does not specify a region. The default region is us-west-2, which does not need to be specified. The linked documentation notes: "use only if your account is not in US West". So specifying an incorrect region could cause connection errors.

Node.js Driver, . If the test is OK, click submit to create the data connector and perform data discovery. 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

Remove the region from the connection information and specify 'account='abc.us-east-1'. The region field is being deprecated and should not be used in connections to Snowflake. https://docs.snowflake.net/manuals/user-guide/nodejs-driver-use.html#establishing-a-connection

Connecting to Snowflake | How-To, is the next-generation command line client for connecting to Snowflake to execute SQL queries and perform all DDL and DML operations, including loading data into and unloading data out of database tables. Written in pure JavaScript, the Node.js driver provides a native asynchronous Node.js interface to Snowflake. The driver supports Node.js versions: v10. v12. v13. (Note: v13 is expected to be supported only through July 2020.) For more information about Node.js, see nodejs.org. The typical workflow for using the driver is:

SnowSQL (CLI Client), How to connect to a Snowflake DB Data Warehouse using the snowflake-sdk driver and Nodejs. Based strictly on code provided, the functional difference between the 2 examples is that the Node.js one specifies the us-east-1 region, and the Python one does not specify a region. The default region is us-west-2, which does not need to be specified.

Connect to Snowflake with Node.js Driver, For more information about Node.js, see nodejs.org. The typical workflow for using the driver is: Establish a connection with Snowflake. Execute statements, e.g.  Snowflake Partner Connect — List of Snowflake partners who offer free trials for connecting to and using Snowflake; includes instructions for starting a trial through the Snowflake web interface. More detailed instructions and trial terms are provided by the individual partners.

Snowflake Node.js Driver, hoeffer (Snowflake)​ can you please share the proxy url format that solved this JDBC connection with a proxy? It would really help other  Using the PUT command to upload local data files on a client machine to an internal (i.e. Snowflake) stage. Using the GET command to download data files from an internal (i.e. Snowflake) stage to a client machine. However, this functionality is currently not supported for Snowflake

Comments
  • Thanks alot @Aneesha! I was having the same problem trying to connect using Spark. I first used the python client where the account is actually "account'+'region", and account for spark is simply the account. That is such a crazy concept. Please keep same standards on the different platforms.