Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pg-copy-streams

Package Overview
Dependencies
Maintainers
3
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-copy-streams

Low-Level COPY TO and COPY FROM streams for PostgreSQL in JavaScript using

  • 5.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
133K
decreased by-7.86%
Maintainers
3
Weekly downloads
 
Created

What is pg-copy-streams?

The pg-copy-streams npm package provides a way to perform high-performance data import and export operations with PostgreSQL using the COPY command. It allows you to stream data to and from PostgreSQL databases efficiently.

What are pg-copy-streams's main functionalities?

COPY FROM

This feature allows you to import data into a PostgreSQL table from a file using the COPY FROM command. The code sample demonstrates how to stream data from a CSV file into a PostgreSQL table.

const { Client } = require('pg');
const copyFrom = require('pg-copy-streams').from;
const fs = require('fs');

const client = new Client();
client.connect();

const stream = client.query(copyFrom('COPY my_table FROM STDIN'));
const fileStream = fs.createReadStream('data.csv');
fileStream.pipe(stream).on('finish', () => {
  console.log('Data imported successfully');
  client.end();
});

COPY TO

This feature allows you to export data from a PostgreSQL table to a file using the COPY TO command. The code sample demonstrates how to stream data from a PostgreSQL table into a CSV file.

const { Client } = require('pg');
const copyTo = require('pg-copy-streams').to;
const fs = require('fs');

const client = new Client();
client.connect();

const stream = client.query(copyTo('COPY my_table TO STDOUT'));
const fileStream = fs.createWriteStream('data.csv');
stream.pipe(fileStream).on('finish', () => {
  console.log('Data exported successfully');
  client.end();
});

Other packages similar to pg-copy-streams

Keywords

FAQs

Package last updated on 07 Jun 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc