Username and Password Authentication
Deprecated Authentication Method
Username/password authentication is being deprecated by Snowflake. Use External OAuth or Key Pair Authentication instead.
See: Planning for the deprecation of single-factor password sign-ins
This example shows basic username and password authentication. If you have Multi-Factor Authentication (MFA) enabled, you’ll need to approve a Duo request on your device during connection.
import { promisifyConnection } from "snowflake-promise";
import snowflake from "snowflake-sdk";
const connection = promisifyConnection(
snowflake.createConnection({
account: "your-account",
username: "your-username",
password: "your-password",
// Optional: specify database, schema, warehouse
})
);
try {
await connection.connect();
console.log("Successfully connected to Snowflake");
} catch (error) {
console.error("Connection failed:", error.message);
return;
}
// Now you can execute queries
// const { resultsPromise } = connection.execute({ sqlText: "SELECT 1" });