jazst21
2/15/2019 - 11:46 AM

sql module export

var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : '127.0.0.1',
  user     : 'root',
  password : '111111'
});


module.exports = class SQL {
  Connect() { connection.connect(function(err) {
    if (err) {
      console.error('error connecting: ' + err.stack);
      return;
    }
    console.log('connected as id ' + connection.threadId);
})}
// connection.query("SELECT * FROM `admin`.Financial WHERE Variable_code = 'H08';", function (error, results, fields) {
// //    console.log(results.length , results[0]);
//     console.log(results[0].Year, results[0].Variable_category )
//   });
Query() { connection.query("select * from `admin`.BalanceView1", function (error, results, fields) {
//    console.log(results.length , results[0]);
    console.log(results)
  });
}

Disconnect() { connection.end(function(err) {
    // The connection is terminated now
    console.log("logging out");
  });
}
};



//export { Connect, Query, Disconnect };