Skip to content

Instantly share code, notes, and snippets.

@b3tts32
Last active September 9, 2017 19:35
Show Gist options
  • Save b3tts32/40a94a85c9adf983266b111e7bdaa6f7 to your computer and use it in GitHub Desktop.
Save b3tts32/40a94a85c9adf983266b111e7bdaa6f7 to your computer and use it in GitHub Desktop.
MySQL Callback Module
var mysql = require('mysql');
var util = require('util');
//New comment for update
var pool = mysql.createPool({
multipleStatements: true,
host: 'localhost',
user: 'root',
database: 'test',
password: 'password',
dateStrings: 'date',
connectionLimit: 20,
});
exports.execSQL = function(sql, callback){
pool.getConnection(function(err,connection){
if (err) throw err;
connection.query(sql, function(err, rows, fields) {
if (err) throw err;
callback(rows);
});
connection.release();
});
}
var db = require('./db');
var sql = "SELECT * from test";
//Query for VDT Number
db.execSQL(sql,function(data) {
console.log(data[0].idtest);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment