panates / postgrejs

Professional PostgreSQL client for NodeJS
https://postgrejs.panates.com
MIT License
50 stars 12 forks source link

Bulk uploading: COPY ... FROM STDIN WITH CSV #11

Open btakita opened 2 years ago

btakita commented 2 years ago

Is your feature request related to a problem? Please describe. Bulk updates are significantly faster using COPY instead of single sql queries.

Describe the solution you'd like

const { stream } = pg.query(` COPY my_table (col1, col2, etc) FROM STDIN WITH CSV`, { stream: true })
createReadStream('./data.csv').on('data', $=>stream.write($)).on('close', ()=>stream.close())

Describe alternatives you've considered

Additional context https://www.citusdata.com/blog/2017/11/08/faster-bulk-loading-in-postgresql-with-copy/

erayhanoglu commented 2 years ago

Hi Brian, thank you for your feedback. COPY operation is not implemented yet. I am marking this issue as a feature request.