mirror of
https://github.com/danbulant/sql2csv
synced 2026-06-19 14:31:38 +00:00
Run query on databse connected
This commit is contained in:
parent
9ab123f431
commit
6915cd06e8
1 changed files with 11 additions and 7 deletions
16
index.js
16
index.js
|
|
@ -100,17 +100,21 @@ con.connect(function(err) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
log("\x1b[32mMySQL Connected!");
|
log("\x1b[32mMySQL Connected!");
|
||||||
});
|
|
||||||
|
|
||||||
s2c.setConnection(con);
|
fs.readdirSync('./input/').forEach(file => {
|
||||||
|
file = "./input/" + file;
|
||||||
fs.readdirSync('./input/').forEach(file => {
|
if(fs.statSync(file).isDirectory()) return;//skip directories
|
||||||
if(fs.statSync(file).isDirectory()) return;//skip directories
|
var query = fs.readFileSync(file);
|
||||||
s2c.query(fs.readFileSync(file))
|
log("Running " + query + " from file " + file);
|
||||||
|
s2c.query(query)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
console.log(result.csv);
|
console.log(result.csv);
|
||||||
log(`Task from file ${file} done in ` + Math.round(result.end - result.start) + "ms");
|
log(`Task from file ${file} done in ` + Math.round(result.end - result.start) + "ms");
|
||||||
con.end();
|
con.end();
|
||||||
})
|
})
|
||||||
.catch(err => {error(err); process.exit(0)})
|
.catch(err => {error(err); process.exit(0)})
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
s2c.setConnection(con);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue