Postgres dump table into file
文章目录
- Using go-pg. To avoid out of memory issue, instead of writing the result to buffer, the result should be written directly to a file. The snippets will be:
1 | //open database connection first |
- Using psql and exec package. Basically, this approach execute a psql command in the form of: psql -c query1 -c query2 … args. Please note, this approach requires that psql is already installed. The snippets:
1 | queries := []string{ |