mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 17:16:01 +00:00
new streams
This commit is contained in:
27
test/importTable.js
Normal file
27
test/importTable.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const dbgateApi = require('@dbgate/api');
|
||||
|
||||
async function run() {
|
||||
const csvReader = await dbgateApi.csvReader({
|
||||
fileName: 'test.csv',
|
||||
header: true,
|
||||
});
|
||||
|
||||
|
||||
const tableWriter = await dbgateApi.tableWriter({
|
||||
connection: {
|
||||
server: 'localhost',
|
||||
engine: 'mysql',
|
||||
user: 'root',
|
||||
password: 'test',
|
||||
port: '3307',
|
||||
database: 'Chinook',
|
||||
},
|
||||
pureName: 'importedTable'
|
||||
});
|
||||
|
||||
const consoleWriter = await dbgateApi.consoleObjectWriter();
|
||||
|
||||
await dbgateApi.copyStream(csvReader, consoleWriter);
|
||||
}
|
||||
|
||||
dbgateApi.runScript(run);
|
||||
Reference in New Issue
Block a user