mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
28 lines
570 B
JavaScript
28 lines
570 B
JavaScript
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);
|