From b98fdb5a6c8526b8a581bdf5763095351f41af83 Mon Sep 17 00:00:00 2001 From: moepoi Date: Mon, 15 Nov 2021 16:58:59 +0700 Subject: [PATCH] Add db connector --- db.js | 16 ---------------- modules/db.js | 11 +++++++++++ 2 files changed, 11 insertions(+), 16 deletions(-) delete mode 100644 db.js create mode 100644 modules/db.js diff --git a/db.js b/db.js deleted file mode 100644 index 047dc94..0000000 --- a/db.js +++ /dev/null @@ -1,16 +0,0 @@ -var mysql = require("mysql"); -var db_connect = mysql.createConnection({ - host: "ruka.moe.team", - user: "admin_nekoya", - password: "Nekoya123.", - database: "admin_nekoya", -}); -db_connect.connect(function (err) { - if (!err) { - console.log("Database Connected !!!"); - } else { - console.log("There was a problem connecting to the database ...."); - } -}); - -module.exports = db_connect; diff --git a/modules/db.js b/modules/db.js new file mode 100644 index 0000000..0681931 --- /dev/null +++ b/modules/db.js @@ -0,0 +1,11 @@ +var mysql = require('mysql2'); +const config = require('../config'); + +function connect(sql, params) { + const connection = mysql.createConnection(config.db); + return connection; +} + +module.exports = { + connect +} \ No newline at end of file