mirror of
https://github.com/danbulant/sql2csv
synced 2026-06-18 22:11:43 +00:00
Better example
This commit is contained in:
parent
0a07c448d9
commit
e68b46120a
1 changed files with 15 additions and 1 deletions
|
|
@ -46,12 +46,26 @@ Usage is pretty straight forward. Currently this package has support only for my
|
||||||
const sql2csv = require("sql2csv");
|
const sql2csv = require("sql2csv");
|
||||||
const mysql = require("mysql");
|
const mysql = require("mysql");
|
||||||
|
|
||||||
|
var con = mysql.createConnection({
|
||||||
|
host: "localhost",
|
||||||
|
user: "root",
|
||||||
|
password: ""
|
||||||
|
});
|
||||||
|
|
||||||
const s2c = new sql2csv({
|
const s2c = new sql2csv({
|
||||||
logging: true,//Log to console
|
logging: true,//Log to console
|
||||||
skipMysqlCheck: true,//Skip mysql check, as it's surely there
|
skipMysqlCheck: true,//Skip mysql check, as it's surely there
|
||||||
colors: true,//Use colors, default value (could be ommited)
|
colors: true,//Use colors, default value (could be ommited)
|
||||||
showNames: true,//Show column names in first row
|
showNames: true,//Show column names in first row
|
||||||
crlf: false,//Use only linux lf
|
crlf: false,//Use only linux lf
|
||||||
conn: conn //Connection to use
|
conn: con //Connection to use
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(s2c.query("SELECT * FROM db.table"));
|
||||||
|
/*
|
||||||
|
Shows something like
|
||||||
|
id,column1,column2
|
||||||
|
1,Daniel,Bulant
|
||||||
|
2,John,Doe
|
||||||
|
*/
|
||||||
`
|
`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue