1

I'm trying to copy the data from an csv file to table in windows cmd using psql. please find the below cmd which I have used,

psql -h localhost -p 5432 -U postgres --dbname postgres -c COPY test FROM 'D:\test\Book1.csv' DELIMITER ',' CSV HEADER; 

and getting an error: extra command line argument.

Here Im looking for the command which connects to DB and loads the data into DB in a single command.

Thanks.

3
  • 1
    You should enclose the command after -c and its arguments in double quotes so that Windows interprets them as a single argument. Commented Oct 9, 2017 at 10:26
  • @LaurenzAlbe: Thank you for the replay,I have done that but its in stand mode doing noting. Commented Oct 9, 2017 at 10:37
  • @LaurenzAlbe: it worked Thanks a lot Commented Oct 9, 2017 at 10:45

1 Answer 1

2

Enclose the SQL statement and its arguments in double quotes, like this:

psql ... -c "COPY test FROM 'D:\test\Book1.csv' DELIMITER ',' CSV HEADER"

Then it will be passed as a single string to -c.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.