谁有一个有效的代码来连接NodeJS和雪花。
已尝试执行以下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());
}
});不断收到错误:
Network error. Could not reach Snowflake.类似地,下面的instructions for Python没有问题(使用与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()发布于 2018-10-28 20:22:23
在python中使用帐户具有类似于"account_id.region“的内容
ctx = snowflake.connector.connect(
user='user1',
password='pass1',
account='abc.us-east-1'
)对于node.js,您需要提供相同的:
var connection = snowflake.createConnection({
account: 'abc',
username: 'user1',
password: 'pass1',
region: 'us-east-1'
});发布于 2019-10-08 07:40:25
从连接信息中删除区域,并指定'account='abc.us-east-1‘。region字段已被弃用,不应在连接到Snowflake时使用。
https://docs.snowflake.net/manuals/user-guide/nodejs-driver-use.html#establishing-a-connection
发布于 2018-09-24 13:20:08
严格根据提供的代码,这两个示例之间的功能差异在于,Node.js示例指定了us-east-1区域,而Python示例没有指定区域。默认区域为us-west-2,无需指定。链接的文档说明:“仅当您的帐户不在美国西部时使用”。因此指定不正确的区域可能会导致连接错误。
https://stackoverflow.com/questions/52429553
复制相似问题