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);

25
test/test.csv Normal file
View File

@@ -0,0 +1,25 @@
1,Rock
2,Jazz
3,Metal
4,Alternative & Punk
5,Rock And Roll
6,Blues
7,Latin
8,Reggae
9,Pop
10,Soundtrack
11,Bossa Nova
12,Easy Listening
13,Heavy Metal
14,R&B/Soul
15,Electronica/Dance
16,World
17,Hip Hop/Rap
18,Science Fiction
19,TV Shows
20,Sci Fi & Fantasy
21,Drama
22,Comedy
23,Alternative
24,Classical
25,Opera
1 1 Rock
2 2 Jazz
3 3 Metal
4 4 Alternative & Punk
5 5 Rock And Roll
6 6 Blues
7 7 Latin
8 8 Reggae
9 9 Pop
10 10 Soundtrack
11 11 Bossa Nova
12 12 Easy Listening
13 13 Heavy Metal
14 14 R&B/Soul
15 15 Electronica/Dance
16 16 World
17 17 Hip Hop/Rap
18 18 Science Fiction
19 19 TV Shows
20 20 Sci Fi & Fantasy
21 21 Drama
22 22 Comedy
23 23 Alternative
24 24 Classical
25 25 Opera