dbgate/test/exportTable.js

68 lines
1.5 KiB
JavaScript
Raw Normal View History

const dbgateApi = require('dbgate-api');
2020-06-04 09:18:46 +00:00
async function run() {
2020-06-11 08:09:04 +00:00
// const queryReader = await dbgateApi.queryReader({
// connection: {
// server: 'localhost',
// engine: 'mysql',
// user: 'root',
// password: 'test',
// port: '3307',
// database: 'Chinook',
// },
// sql: 'SELECT * FROM Genre',
// });
2020-06-04 09:18:46 +00:00
const queryReader = await dbgateApi.queryReader({
connection: {
server: 'localhost',
2020-06-11 08:09:04 +00:00
engine: 'mssql',
user: 'sa',
password: 'Pwd2020Db',
2020-06-04 09:18:46 +00:00
database: 'Chinook',
},
sql: 'SELECT * FROM Genre',
});
// const queryReader = await dbgateApi.fakeObjectReader({ delay: 1000 });
const csvWriter = await dbgateApi.csvWriter({
fileName: 'test.csv',
2020-06-11 08:09:04 +00:00
// header: false,
2020-06-04 09:18:46 +00:00
});
2020-06-11 18:52:57 +00:00
const jsonWriter = await dbgateApi.jsonLinesWriter({
fileName: 'test.jsonl',
header: false,
});
2020-06-10 19:35:25 +00:00
const consoleWriter = await dbgateApi.consoleObjectWriter();
2020-06-11 18:52:57 +00:00
// await dbgateApi.copyStream(queryReader, csvWriter);
await dbgateApi.copyStream(queryReader, jsonWriter);
2020-06-10 19:35:25 +00:00
// await dbgateApi.copyStream(queryReader, consoleWriter);
2020-06-04 09:18:46 +00:00
}
dbgateApi.runScript(run);
2020-06-06 19:48:29 +00:00
// dbgateApi.runBatch([
// {
// type: 'copyStream',
// source: {
// type: 'queryReader',
// connection: {
// server: 'localhost',
// engine: 'mysql',
// user: 'root',
// password: 'test',
// port: '3307',
// database: 'Chinook',
// },
// sql: 'SELECT * FROM Genre',
// },
// target: {
// type: 'csvWriter',
// },
// },
// ]);