Last active
September 9, 2017 19:35
-
-
Save b3tts32/40a94a85c9adf983266b111e7bdaa6f7 to your computer and use it in GitHub Desktop.
MySQL Callback Module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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