I am trying to use a psql
loop to load a directory of csv files into an AWS RDS Postgres database.
This StackExchange post answers how to do so locally and the following code works with a single file:
PGPASSWORD='MyPassword' psql -h my-rds.instance.us-east-1.rds.amazonaws.com -U user -d mydatabase -c '\COPY dbo.input_table FROM ''MySingleFile.csv'' CSV HEADER'
but I can't "combine" the two features. This code is the closest I can get but I get the following error for each file that is identified by the ls *.csv
command:
for x in $(ls *.csv);
do PGPASSWORD='MyPassword' psql -h my-rds.instance.us-east-1.rds.amazonaws.com -U user -d mydatabase -c "\COPY dbo.input_table FROM ''MySingleFile.csv'' CSV HEADER"; done
ERROR: conflicting or redundant options
...
ERROR: conflicting or redundant options