Created
February 9, 2021 07:43
-
-
Save bastienapp/78b2de01d5db676e434f60ef2a04f6e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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