'vagrant postgreSQL run COPY
I want to COPY rows from a CSV file (From my Mac locally) into my postgreSQL DB, which is running on Vagrant.
As far as I know the COPY command can only be runned as super user.
This would be the command which fits:
COPY part_model FROM '/Users/myusername/Desktop/csv-file-to-import.csv' csv header;
Then running from my Terminal in the project folder I also have my Vagrantfile and I usually create the vagrant machine, I tried to run this command:
vagrant ssh -c "sudo su - postgres -c 'psql -d databasename name -U username -h localhost COPY part_model FROM '/Users/myusername/Desktop/part_model-import.csv' csv header'";
But I get this error/warning:
psql: warning: extra command-line argument "COPY" ignored
psql: warning: extra command-line argument "part_model" ignored
psql: warning: extra command-line argument "FROM" ignored
psql: warning: extra command-line argument "/Users/antonhorl3/Desktop/part_model- Import.csv" ignored
psql: warning: extra command-line argument "csv" ignored
psql: warning: extra command-line argument "header" ignored
Any help appreciated! Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
