Skip to content

Instantly share code, notes, and snippets.

@bastienapp
Created February 9, 2021 07:43
Show Gist options
  • Save bastienapp/78b2de01d5db676e434f60ef2a04f6e3 to your computer and use it in GitHub Desktop.
Save bastienapp/78b2de01d5db676e434f60ef2a04f6e3 to your computer and use it in GitHub Desktop.
require('dotenv').config()
const mysql = require('mysql2')
const config = {
host: process.env.DB_HOST,
port: process.env.DB_PORT,
user: process.env.DB_USER,
password: process.env.DB_PASS,
database: process.env.DB_NAME,
}
const connection = mysql.createPool(config)
connection.getConnection((err, connection) => {
if (err) {
console.error(err)
} else {
console.log('Database connected')
}
})
module.exports = connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment