Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
connection.prototype.connect = function(callback){
var self = this;
self.connection = snowflake.createConnection(self.options);
self.connection.connect(function(err, conn) {
if (err) {
self.book.logger.log('Unable to connect: ' + err.message, 'error');
callback(err);
} else {
self.showTables(function(error, tables){
callback(error);
});
}
});
};
constructor(config) {
super();
this.config = {
account: process.env.CUBEJS_DB_SNOWFLAKE_ACCOUNT,
region: process.env.CUBEJS_DB_SNOWFLAKE_REGION,
warehouse: process.env.CUBEJS_DB_SNOWFLAKE_WAREHOUSE,
database: process.env.CUBEJS_DB_NAME,
username: process.env.CUBEJS_DB_USER,
password: process.env.CUBEJS_DB_PASS,
...config
};
const connection = snowflake.createConnection(this.config);
this.initialConnectPromise = new Promise(
(resolve, reject) => connection.connect((err, conn) => (err ? reject(err) : resolve(conn)))
);
}
return await new Promise((resolve, reject) => {
snowflake
.createConnection({
account: snowflakeCredentials.accountId,
username: snowflakeCredentials.username,
password: snowflakeCredentials.password,
database: snowflakeCredentials.databaseName,
warehouse: snowflakeCredentials.warehouse,
role: snowflakeCredentials.role
})
.connect((err, conn) => {
if (err) {
reject(err);
} else {
resolve(conn);
}
});
});