
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
db-streamer
Advanced tools
A library to stream data into a SQL database. Currently supports streaming data into PostgreSQL or MySQL tables.
In order to use this library, you must also install the additional libraries in your project depending on the database that you use.
npm install pg --save
npm install pg-copy-streams --save
npm install pg-hstore --save
npm install mysql --save
npm install streamsql --save
var dbStreamer = require('db-streamer'),
connString = 'postgres://streamer:streamer@localhost:5432/streamer-test';
// create inserter
var inserter = dbStreamer.getInserter({
dbConnString: connString,
tableName: 'test_table',
columns: ['a', 'b', 'c']
});
// establish connection
inserter.connect(function(err, client) {
// push some rows
inserter.push({a: 1, b: 'one', c: new Date() });
inserter.push({a: 2, b: 'two', c: new Date() });
inserter.push({a: 3, b: 'three', c: new Date() });
// create child table inserter using deferring strategy
// this is useful to avoid missing foreign key conflicts as a result of race conditions
var childInserter = dbStreamer.getInserter({
dbConnString: connString,
tableName: 'child_table',
columns: ['a', 'd', 'e'],
deferUntilEnd: true
});
childInserter.push({a: 2, d: 'asdf', e: new Date() });
childInserter.push({a: 3, d: 'ghjk', e: new Date() });
childInserter.setEndHandler(callback);
// set end callback
inserter.setEndHandler(function() {
childInserter.end();
});
// announce end
inserter.end();
});
Key | Description |
---|---|
dbConnString | A database connection string. |
tableName | The tablename to insert into. |
columns | Array of column names. |
primaryKey | Required if using MySQL. String of the primary key (defaults to id if omitted). |
deferUntilEnd | Boolean (default=false). Stream output to temporary file which is then streamed in all at once into table upon calling end . |
Key | Description |
---|---|
useSequelizeBulkInsert | Boolean. Perform the insert using a combination of async.cargo and sequelize bulkInsert. Must provide sequelizeModel parameter too. |
sequelizeModel | The sequelize model to perform a bulk insert with. |
deferUntilEnd | Boolean (default=false). Pause all cargo iterations until calling end . |
FAQs
A library to stream data into a SQL database.
The npm package db-streamer receives a total of 26 weekly downloads. As such, db-streamer popularity was classified as not popular.
We found that db-streamer demonstrated a not healthy version release cadence and project activity because the last version was released 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.