Add db connector

This commit is contained in:
Moe Poi ~ 2021-11-15 16:58:59 +07:00
parent fbe9fb39c5
commit b98fdb5a6c
2 changed files with 11 additions and 16 deletions

16
db.js
View file

@ -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;

11
modules/db.js Normal file
View file

@ -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
}