Import/Export DB table <-> CSV file.
Install dependecies.
bundle config set path vendor/bundle
bundle install
Make .env
and add DB_URL
.
e.g.
DB_URL='postgres://<user>:<password>@<host>:<port>/<DB>'
bundle exec ruby src/db2csv.rb <table name>
If the table under a schema:
bundle exec ruby src/db2csv.rb <schema name>.<table name>
bundle exec ruby src/csv2db.rb <table name>
If the table under a schema:
bundle exec ruby src/csv2db.rb <schema name>.<table name>
If delete all and insert, add --sync
option:
bundle exec ruby src/db2csv.rb <table name> --sync
bundle exec ruby src/csv2db.rb <table name> --sync
CSV file must include column names.
And, exported CSV file include column names.