Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mysql = require('mysql');
- var pool = mysql.createPool({
- connectionLimit: 5,
- host: 'localhost',
- user: 'root',
- password: '',
- database: 'final_project'
- });
- exports.executeQuery = function (query, vals, callback) {
- pool.getConnection(function (err, connection) {
- if (err) {
- connection.release();
- callback(err, null);
- }
- connection.query(query, vals, function (err, rows, fields) {
- connection.release();
- if (!err) {
- callback(null, rows);
- }
- });
- connection.on('error', function (err) {
- callback(err, null);
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement