Created
September 1, 2021 10:59
-
-
Save aqkhan/d2691c393d95b768acebce11d1169b07 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
const mysql = require("mysql"); | |
const dotenv = require("dotenv"); | |
dotenv.config(); | |
// Create a connection to the database | |
const connection = mysql.createConnection({ | |
host: process.env.DB_HOST, | |
user: process.env.DB_USER, | |
password: process.env.DB_PASSWORD, | |
database: process.env.DB_NAME, | |
}); | |
// open the MySQL connection | |
connection.connect((error) => { | |
if (error) throw error; | |
console.log("Successfully connected to the database."); | |
}); | |
module.exports = connection; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment