mirror of
https://github.com/danbulant/sql2csv
synced 2026-05-19 04:18:33 +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({
|
||||
logging: true,
|
||||
skipMysqlCheck: true,
|
||||
colors: true
|
||||
colors: true,
|
||||
showNames: false,
|
||||
crlf: false
|
||||
});
|
||||
|
||||
log();
|
||||
|
|
@ -81,6 +83,8 @@ if(config.password == undefined){
|
|||
warn("Undefined password, using (empty)");
|
||||
config.password = "";
|
||||
}
|
||||
if(config.showNames) s2c.setOption("showNames", true);
|
||||
if(config.crlf) s2c.setOption("crlf", true);
|
||||
|
||||
var con = mysql.createConnection({
|
||||
host: config.host,
|
||||
|
|
@ -99,3 +103,14 @@ con.connect(function(err) {
|
|||
});
|
||||
|
||||
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