Skip to content

Instantly share code, notes, and snippets.

@tkssharma
Created February 14, 2019 15:51
Show Gist options
  • Save tkssharma/5e11319d98a76369fc7e9a87312aab9a to your computer and use it in GitHub Desktop.
Save tkssharma/5e11319d98a76369fc7e9a87312aab9a to your computer and use it in GitHub Desktop.
const mysql = require('mysql2/promise');
const config = {
user: 'root',
password: 'root',
database: 'testdb',
host: 'mysql',
connectTimeout: 80000,
};
mysql.createConnection(config)
.then((connection) => {
console.log(`connection established to local ${config.database} database`);
global.MYconnection = connection;
})
.catch((e) => {
console.log(e);
eventEmitter.emit('connectionFailed', 'Destination');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment