mirror of
https://github.com/danbulant/sql2csv
synced 2026-06-20 23:11:12 +00:00
Update wrapper
This commit is contained in:
parent
0044bd0518
commit
cb3ee1a081
1 changed files with 16 additions and 1 deletions
17
index.js
17
index.js
|
|
@ -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)})
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue