0

I would like to run the two sql commands sequentially but i can't able to achieve it.

Here is my shell script

#! /bin/bash

gsutil cp gs://api-bucket-germany/order_status.csv ./order_status.csv

psql -d apidbgermany -U apidbgermany << EOF

DELETE FROM apidbgermany.order_status
\copy apidbgermany.order_status from './order_status.csv' delimiter ',' CSV;
EOF

It is executing copy then delete.

1 Answer 1

1

It is most likely failing all together; you are missing a ; at the end of your DELETE statement. Try:

#! /bin/bash

gsutil cp gs://api-bucket-germany/order_status.csv ./order_status.csv

psql -d apidbgermany -U apidbgermany << EOF

DELETE FROM apidbgermany.order_status;
\copy apidbgermany.order_status from './order_status.csv' delimiter ',' CSV;
EOF

For debugging scripts it's generally helpful to run the commands manually first by connecting and cut-and-pasting the script sql to make sure it works before trying it in the script.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.