26 lines
473 B
JavaScript
26 lines
473 B
JavaScript
var mysql = require('mysql');
|
|
var fs = require("fs");
|
|
|
|
var file = null;
|
|
var connection = null;
|
|
|
|
try {
|
|
file = fs.readFileSync("./config.json");
|
|
}
|
|
catch(exception) {
|
|
console.log(exception.toString());
|
|
}
|
|
|
|
if(file != null) {
|
|
var json = JSON.parse(file);
|
|
|
|
connection = mysql.createConnection({
|
|
host: json.host,
|
|
database: json.database,
|
|
user: json.user,
|
|
password: json.password
|
|
});
|
|
}
|
|
|
|
|
|
module.exports = connection;
|