0.0.4 • Published 6 months ago
pg-upload v0.0.4
Install
npm install pg-upload
API
upload(dp: pg.Pool, file: string, sql: string): Promise<void>
Use
Upload a local CSV-file to a database server for import using the PostgreSQL copy command:
import pg from 'pg';
import { upload } from 'pg-upload';
const db = new pg.Pool({...});
await upload(
db,
'some/path/to/data.csv',
`copy target_table (col1, col2, col3)
from stdin
with csv header encoding 'UTF-8'
`
);