A postgresql tool,support export psql data to csv and import csv back to psql.
Support dataType:
- text
- bigint
- boolean
- text[]
- numeric
- inet
- timestamp
clone source:
git clone https://github.com/Kseleven/psql2csv.git
go run cmd/pg2csv.go --helpinstall
go install github.com/Kseleven/psql2csv@latest
pg2csv --helpexport and import tables:
-
configuration file is below examples path,copy and modify it,then execute command below:
go run cmd/pg2csv.go -f {yourpath}/examples/example.json -
You wil get table.csv files in "exportPath" specified in example.json.
-
Change parameter "action" in example.json to "import", and modify new database config
-
Execute command to import csv to new database
go run cmd/pg2csv.go -f {yourpath}/examples/example.json -
If new database column is diff with csv header, it will print different column. Then you should add or delete csv header to keep same with new database column.
-
After modify csv header and data, execute import command again.