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
.. image:: https://github.com/snowflakedb/snowflake-connector-nodejs/workflows/Build%20and%20Test/badge.svg?branch=master :target: https://github.com/snowflakedb/snowflake-connector-nodejs/actions?query=workflow%3A%22Build+and+Test%22+branch%3Amaster
.. image:: https://img.shields.io/npm/v/snowflake-sdk.svg :target: https://www.npmjs.com/package/snowflake-sdk
.. image:: http://img.shields.io/:license-Apache%202-brightgreen.svg :target: http://www.apache.org/licenses/LICENSE-2.0.txt
Include :code:snowflake-sdk
in :code:dependencies
section in :code:package.json
:
.. code-block:: json
{
"name": "<your_application_name>",
"version": "<your_application_version>",
"dependencies": {
"...": "...",
"snowflake-sdk": "^1.1.0",
"...": "..."
}
}
And run the :code:npm install
.
For detailed documentation and basic usage examples, please see the documentation
at NodeJS Driver for Snowflake <https://docs.snowflake.net/manuals/user-guide/nodejs-driver.html>
_
Set the Snowflake connection info in parameters.json
and place it in $HOME:
.. code-block:: json
{
"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>"
}
}
.. code-block:: bash
npm test
To specify which test to run, change the "test" value on "package.json":
.. code-block:: json
"scripts": { "test": "mocha test/unit/snowflake_test.js" },
To run all unit test:
.. code-block:: json
"scripts": { "test": "mocha test/unit/**/*.js" },
The npm package can be built by the command:
.. code-block:: bash
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.
.. code-block:: bash
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.