All files runsqlfile.js

71.43% Statements 10/14
50% Branches 2/4
100% Functions 3/3
71.43% Lines 10/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 331x 1x   1x     2x 2x   2x             2x   2x 2x             2x            
var mysql = require("mysql");
var fs = require("fs");
 
module.exports = function run(filename, pool, done)
{
	// console.log("runsqlfile: reading file " + filename);
	let sql = fs.readFileSync(filename, "utf8");
	pool.getConnection((err, connection) =>
	{
		Iif (err)
		{
			console.log("runsqlfile: error connecting:" + err);
			done();
		}
		else
		{
			connection.query(sql, (err) =>
			{
				connection.release();
				Iif (err)
				{
					console.log(err);
					done();
				}
				else
				{
					done();
				}
			});
		}
	});
};