We can load large files like CSV into our postgres database usong COPY command. Below is an example to do so:
export PGPASSWORD='your_password'; psql -h hotsname -p port-U username -d database -c "\copy table_name FROM 'location of file' WITH DELIMITER '|' CSV HEADER;"
Just put in the parameters required. You can adjust the delimiter as needed like ',' or ';'
export PGPASSWORD='your_password'; psql -h hotsname -p port-U username -d database -c "\copy table_name FROM 'location of file' WITH DELIMITER '|' CSV HEADER;"
Just put in the parameters required. You can adjust the delimiter as needed like ',' or ';'
No comments:
Post a Comment