mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
26 lines
564 B
JavaScript
26 lines
564 B
JavaScript
|
const dbgateApi = require('@dbgate/api');
|
||
|
|
||
|
async function run() {
|
||
|
const queryReader = await dbgateApi.queryReader({
|
||
|
connection: {
|
||
|
server: 'localhost',
|
||
|
engine: 'mysql',
|
||
|
user: 'root',
|
||
|
password: 'test',
|
||
|
port: '3307',
|
||
|
database: 'Chinook',
|
||
|
},
|
||
|
sql: 'SELECT * FROM Genre',
|
||
|
});
|
||
|
|
||
|
// const queryReader = await dbgateApi.fakeObjectReader({ delay: 1000 });
|
||
|
|
||
|
const csvWriter = await dbgateApi.csvWriter({
|
||
|
fileName: 'test.csv',
|
||
|
});
|
||
|
|
||
|
await dbgateApi.copyStream(queryReader, csvWriter);
|
||
|
}
|
||
|
|
||
|
dbgateApi.runScript(run);
|