dbgate/plugins/dbgate-plugin-csv
Jan Prochazka 968e69c7f2
Some checks are pending
Run tests / test-runner (push) Waiting to run
DBGATE_TOOLS => DBGATE_PACKAGES
2024-08-20 12:18:55 +02:00
..
src DBGATE_TOOLS => DBGATE_PACKAGES 2024-08-20 12:18:55 +02:00
icon.svg
package.json changed license, added LICENSE-OLD to plugin-oracle 2024-06-26 20:41:14 +02:00
prettier.config.js
README.md
webpack-backend.config.js
webpack-frontend.config.js DBGATE_TOOLS => DBGATE_PACKAGES 2024-08-20 12:18:55 +02:00

styled with prettier NPM version

dbgate-plugin-csv

CSV import/export plugin for DbGate

Usage without DbGate

Export from fake object reader into CSV file. Fake object file can be replaced with other reader/writer factory functions, as described in dbgate-api package

const dbgateApi = require('dbgate-api');
const dbgatePluginCsv = require("dbgate-plugin-csv");

dbgateApi.registerPlugins(dbgatePluginCsv);


async function run() {
  const reader = await dbgateApi.fakeObjectReader();
  const writer = await dbgatePluginCsv.shellApi.writer({ fileName: 'myfile1.csv', separator: ';' });
  await dbgateApi.copyStream(reader, writer);
  
  console.log('Finished job script');
}
dbgateApi.runScript(run);


Factory functions

shellApi.reader

Reads CSV file

  const dbgatePluginCsv = require("dbgate-plugin-csv");
  const reader = await dbgatePluginCsv.shellApi.reader({
    fileName: 'test.csv',
    encoding: 'utf-8',
    header: true,
    delimiter: ',',
    quoted: false,
    limitRows: null
  });

shellApi.writer

Writes CSV file

  const dbgatePluginCsv = require("dbgate-plugin-csv");
  const writer = await dbgatePluginCsv.shellApi.writer({
    fileName: 'test.csv',
    encoding: 'utf-8',
    header: true,
    delimiter: ',',
    quoted: false
  });