
Security News
Insecure Agents Podcast: Certified Patches, Supply Chain Security, and AI Agents
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.
dbgate-api
Advanced tools
Allows run DbGate data-manipulation scripts.
yarn add dbgate-api
This example exports table Customer info CSV file.
const dbgateApi = require('dbgate-api');
const dbgatePluginMysql = require("dbgate-plugin-mysql");
const dbgatePluginCsv = require("dbgate-plugin-csv");
dbgateApi.registerPlugins(dbgatePluginMysql);
async function run() {
const reader = await dbgateApi.tableReader({
connection: { server: 'localhost', engine: 'mysql@dbgate-plugin-mysql', user: 'root', password: 'xxxx', database: 'Chinook' },
pureName: 'Customer',
});
const writer = await dbgatePluginCsv.shellApi.writer({ fileName: 'Customer.csv' });
await dbgateApi.copyStream(reader, writer);
console.log('Finished job script');
}
dbgateApi.runScript(run);
Silly example, runs without any dependencies. Copy fakeObjectReader to consoleObjectWriter .
const dbgateApi = require('dbgate-api');
async function run() {
const reader = await dbgateApi.fakeObjectReader();
const writer = await dbgateApi.consoleObjectWriter();
await dbgateApi.copyStream(reader, writer);
console.log('Finished job script');
}
dbgateApi.runScript(run);
Copies data from reader into writer. Reader and writer should be created from functions listed below.
await dbgateApi.copyStream(reader, writer);
Reads table or view.
const reader = await dbgateApi.tableReader({
connection: { server: 'localhost', engine: 'postgres@dbgate-plugin-postgres', user: 'root', password: 'xxxx', database: 'DB_NAME' },
schemaName: 'public',
pureName: 'Customer',
});
Executes query and reads its result.
const reader = await dbgateApi.tableReader({
connection: { server: 'localhost', engine: 'mysql@dbgate-plugin-mysql', user: 'root', password: 'xxxx', database: 'DB_NAME' },
sql: 'SELECT * FROM Album',
});
Imports data into table. Options are optional, default values are false.
const reader = await dbgateApi.tableWriter({
connection: { server: 'localhost', engine: 'mysql@dbgate-plugin-mysql', user: 'root', password: 'xxxx', database: 'DB_NAME' },
pureName: 'Customer',
options: {
dropIfExists: false,
truncate: false,
createIfNotExists: false,
}
});
Reads JSON lines data file. On first line could be structure. Every line contains one row as JSON serialized object.
const reader = await dbgateApi.jsonLinesReader({
fileName: 'test.jsonl',
encoding: 'utf-8',
header: true,
limitRows: null
});
Writes JSON lines data file. On first line could be structure. Every line contains one row as JSON serialized object.
const reader = await dbgateApi.jsonLinesWriter({
fileName: 'test.jsonl',
encoding: 'utf-8',
header: true
});
FAQs
Allows run DbGate data-manipulation scripts.
The npm package dbgate-api receives a total of 53 weekly downloads. As such, dbgate-api popularity was classified as not popular.
We found that dbgate-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.

Security News
The planned feature introduces a review step before releases go live, following the Shai-Hulud attacks and a rocky migration off classic tokens that disrupted maintainer workflows.