All files runsqlfile.js

76.47% Statements 13/17
50% Branches 2/4
100% Functions 3/3
76.47% Lines 13/17
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 261x 1x   1x 3x 3x 3x 3x       3x 3x 3x 3x       3x 3x            
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");
      done();
    } else {
      console.log("runsqlfile: connected");
      connection.query(sql, (err, rows) => {
        connection.release();
        Iif (err) {
          console.log(err);
          done();
        } else {
          console.log("runsqlfile: run ok");
          done();
        }
      });
    }
  });
};