3

I have a shell script that runs a command:

psql -h $DBHOST -U $DBUSERNAME -c "\copy sometable FROM '$PWD/sometable.csv' WITH DELIMITER ',' CSV HEADER"

which works fine.

Now, as I have some requirements to implement more advanced logic, I am migrating some of these commands to nodejs code.

Is it possible to run this \copy command with postgres-node?

If not, I see an alternative to run this command as it is as a shell command from nodejs with require('child_process').spawn.

1 Answer 1

4

you are looking for https://github.com/brianc/node-pg-copy-streams I suppose. It's same authors "extension" to node-pg

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.