deliverr / data-knex-snowflake-dialect

knex.js dialect for the Snowflake data warehouse
MIT License
13 stars 26 forks source link

Unable to acquire a connection #60

Open alucryd opened 1 year ago

alucryd commented 1 year ago

Hi there, I can't get this to work with either the connection URL nor the breakdown. It works fine using vanilla snowflake driver though, so I have no idea whether this is a bug or I'm doing something wrong. Any idea how to debug?

Connection URL and breakdown shown below:

export const snowflake = knex({
  client: SnowflakeDialect,
  debug: config.logLevel === 'debug',
  connection: `snowflake://${config.snowflakeUser}:${config.snowflakePassword}@${config.snowflakeAccount}.snowflakecomputing.com/${config.snowflakeDatabase}?warehouse=${config.snowflakeWarehouse}`,
  pool: {
    min: 1,
    max: 1,
  },
  // connection: {
  //   host: `${config.snowflakeAccount}.snowflakecomputing.com`,
  //   user: config.snowflakeUser,
  //   password: config.snowflakePassword,
  //   database: config.snowflakeDatabase,
  //   connectAttributes: {
  //     warehouse: config.snowflakeWarehouse,
  //   },
  // },
  // pool: {
  //   min: config.snowflakePoolMinConnections,
  //   max: config.snowflakePoolMaxConnections,
  // },
});

Working snippet from the snowflake documentation:

  const connection = snowflakeSdk.createConnection({
    account: config.snowflakeAccount,
    username: config.snowflakeUser,
    password: config.snowflakePassword,
    warehouse: config.snowflakeWarehouse,
    database: config.snowflakeDatabase,
    application: 'api',
  });

  connection.connect(function (err, conn) {
    if (err) {
      logger.error('Unable to connect: ' + err.message);
    } else {
      logger.info('Successfully connected to Snowflake.');
    }
  });
NicLee0521 commented 1 year ago

After some digging I found the reason to be a missing driverName declaration according to the knex docs just submitted a pr to get this fixed.