export CSV from mysql test

This commit is contained in:
Jan Prochazka
2020-06-04 11:18:46 +02:00
parent d05b319030
commit afbec02f3a
13 changed files with 185 additions and 2 deletions

25
test/exportTable.js Normal file
View File

@@ -0,0 +1,25 @@
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);