Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
snowflake-sdk
Advanced tools
The snowflake-sdk npm package is a Node.js driver for connecting to Snowflake, a cloud-based data warehousing service. It allows you to execute SQL queries, manage transactions, and handle various database operations programmatically.
Connecting to Snowflake
This feature allows you to establish a connection to a Snowflake database using the provided account credentials and connection details.
const snowflake = require('snowflake-sdk');
const connection = snowflake.createConnection({
account: 'your_account',
username: 'your_username',
password: 'your_password',
warehouse: 'your_warehouse',
database: 'your_database',
schema: 'your_schema'
});
connection.connect((err, conn) => {
if (err) {
console.error('Unable to connect: ' + err.message);
} else {
console.log('Successfully connected to Snowflake.');
}
});
Executing SQL Queries
This feature allows you to execute SQL queries against the connected Snowflake database and handle the results.
connection.execute({
sqlText: 'SELECT * FROM your_table',
complete: (err, stmt, rows) => {
if (err) {
console.error('Failed to execute statement due to the following error: ' + err.message);
} else {
console.log('Number of rows produced: ' + rows.length);
console.log(rows);
}
}
});
Managing Transactions
This feature allows you to manage transactions by beginning, committing, and rolling back transactions within the Snowflake database.
connection.execute({
sqlText: 'BEGIN TRANSACTION',
complete: (err, stmt, rows) => {
if (err) {
console.error('Failed to begin transaction: ' + err.message);
} else {
console.log('Transaction started.');
// Perform other operations within the transaction
connection.execute({
sqlText: 'COMMIT',
complete: (err, stmt, rows) => {
if (err) {
console.error('Failed to commit transaction: ' + err.message);
} else {
console.log('Transaction committed.');
}
}
});
}
}
});
The pg package is a PostgreSQL client for Node.js. It provides similar functionalities for connecting to and interacting with PostgreSQL databases, including executing SQL queries and managing transactions. However, it is specific to PostgreSQL and does not support Snowflake.
The mysql package is a Node.js client for MySQL databases. It offers similar capabilities for connecting to MySQL databases, executing queries, and managing transactions. Like pg, it is specific to MySQL and does not support Snowflake.
The mssql package is a Microsoft SQL Server client for Node.js. It provides functionalities for connecting to SQL Server databases, executing queries, and managing transactions. It is specific to SQL Server and does not support Snowflake.
NodeJS Driver for Snowflake
:exclamation: | For production-affecting issues related to the driver, please create a case with Snowflake Support. |
---|
Include snowflake-sdk
in dependencies
section in package.json
{
"name": "",
"version": "",
"dependencies": {
"...": "...",
"snowflake-sdk": "^1.1.0",
"...": "..."
}
}
And run the npm install
For detailed documentation and basic usage examples, please see the documentation at NodeJS Driver for Snowflake.
Set the Snowflake connection info in parameters.json
and place it in $HOME:
{
"testconnection": {
"SNOWFLAKE_TEST_USER": "<your_user>",
"SNOWFLAKE_TEST_PASSWORD": "<your_password>",
"SNOWFLAKE_TEST_ACCOUNT": "<your_account>",
"SNOWFLAKE_TEST_WAREHOUSE": "<your_warehouse>",
"SNOWFLAKE_TEST_DATABASE": "<your_database>",
"SNOWFLAKE_TEST_SCHEMA": "<your_schema>",
"SNOWFLAKE_TEST_ROLE": "<your_role>"
}
}
npm test
To specify which test to run, change the "test" value on "package.json":
"scripts": {
"test": "mocha test/unit/snowflake_test.js"
},
To run all unit test:
"scripts": {
"test": "mocha test/unit/**/*.js"
},
cd snowflake-connector-nodejs
npm install .
npm install nyc
"scripts": {
"test": "nyc mocha test/**/*.js"
},
SNOWFLAKE_TEST_USER="user" SNOWFLAKE_TEST_PASSWORD="password" SNOWFLAKE_TEST_ACCOUNT="account" SNOWFLAKE_TEST_WAREHOUSE="warehouse" SNOWFLAKE_TEST_DATABASE="db" SNOWFLAKE_TEST_SCHEMA="schema" npm test
Note: git bash is the console used for installing the node connector, the nyc module, and running "npm test"
The npm package can be built by the command:
npm pack
Note it is not required to build a package to run tests blow.
Use WebStorm code style file to format the source code.
format.sh -mask "*.js" -settings $(pwd)/webstorm-codestyle.xml -R $(pwd)/lib/ -R $(pwd)/test -R $(pwd)/system_test
FAQs
Node.js driver for Snowflake
The npm package snowflake-sdk receives a total of 229,535 weekly downloads. As such, snowflake-sdk popularity was classified as popular.
We found that snowflake-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.