node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

epf-pg-importer

epf-pg-importer

Take parsed Apple iTunes Enterprise Partner Feed data and import it into a PostgreSQL table, using a streaming COPY.

Usage

'use strict';
 
const parse = require('epf-parser');
const pgImport = require('epf-pg-importer');
const fs = require('fs');
const pg = require('pg');
 
var client = new pg.Client;
client.connect(err => {
  if (err) throw err;
 
  console.log('Starting import...');
 
  fs.createReadStream('/Users/julian/Downloads/itunes20160518/application')
    .pipe(parse((meta, rows) => {
      pgImport({
        client,
        table: 'application',
        meta
      }, (err, copy) => {
        if (err) throw err;
 
        rows.pipe(copy).on('finish', () => {
          console.log('Done! Disconnecting...');
          client.on('drain', () => client.end());
        });
      });
    }));
  
});

License

MIT