Update wrapper

This commit is contained in:
danbulant 2019-09-28 17:03:43 +02:00
parent 0044bd0518
commit cb3ee1a081

View file

@ -35,7 +35,9 @@ log();
const s2c = new sql2csv({ const s2c = new sql2csv({
logging: true, logging: true,
skipMysqlCheck: true, skipMysqlCheck: true,
colors: true colors: true,
showNames: false,
crlf: false
}); });
log(); log();
@ -81,6 +83,8 @@ if(config.password == undefined){
warn("Undefined password, using (empty)"); warn("Undefined password, using (empty)");
config.password = ""; config.password = "";
} }
if(config.showNames) s2c.setOption("showNames", true);
if(config.crlf) s2c.setOption("crlf", true);
var con = mysql.createConnection({ var con = mysql.createConnection({
host: config.host, host: config.host,
@ -99,3 +103,14 @@ con.connect(function(err) {
}); });
s2c.setConnection(con); s2c.setConnection(con);
fs.readdirSync('./input/').forEach(file => {
if(fs.statSync(file).isDirectory()) return;//skip directories
s2c.query(fs.readFileSync(file))
.then(result => {
console.log(result.csv);
log(`Task from file ${file} done in `` + Math.round(result.end - result.start) + "ms");
con.end();
})
.catch(err => {error(err); process.exit(0)})
});