Skip to content

Instantly share code, notes, and snippets.

@4xle
4xle / mssql-stream-insert-example.js
Created June 7, 2018 18:54 — forked from johndstein/mssql-stream-insert-example.js
Working example of Node.js readable and writable stream implementation
'use strict';
// This is a working example of a readable stream sending rows to insert into
// SQL Server.
const Readable = require('stream').Readable;
const mssql = require('mssql');
const MsSqlStreamInsert = require('../../lib/source/mssql-stream-insert');
const showProgress = require('../../lib/transform/show-progress')();
const options = require('../../.config');
@4xle
4xle / any-source-readable.js
Created June 7, 2018 18:54 — forked from johndstein/any-source-readable.js
Custom Node.js readable stream that accepts data from any source
'use strict';
const Readable = require('stream').Readable;
// Easily turn anything into a readable stream.
// This is pretty much taken verbatim from the node documentation. Why re-invent
// the wheel?
// https://nodejs.org/api/stream.html#stream_readable_push_chunk_encoding
@4xle
4xle / mssql-stream-insert.js
Created March 18, 2018 02:29 — forked from johndstein/mssql-stream-insert.js
Node.js writable stream that connects to db, drops and creates table, and then bulk loads rows into table
#!/usr/bin/env node
'use strict';
// Stream unlimited rows into a Sql Server table.
// WARNING!!! WE DROP and RE-CREATE the table. Then stream the data into it.
// Source stream must be an object stream. Object property names must match
// table column names. Since SQL Server isn't case sensitive, don't think case