Exporting a Postgres Database to an Excel Spreadsheet Exporting a Postgres Database to an Excel Spreadsheet postgresql postgresql

Exporting a Postgres Database to an Excel Spreadsheet


If the solution doesn't have to be programmatic, this should help: archives.postgresql.org article


This is not really a programming answer, but this has already been programmed, if exporting to CSV is acceptable.

You can look into:

  • using COPY,
  • using the \o or \copy commands in psql (there's quite a lot of references if you google something like "psql export csv"),
  • if you have a tool like pgAdmin, you can export the results of a query in File->Export...


If you have access to a Mac then Navicat for PostgreSQL Lite will allow you to do exactly this and is available for free in the Mac App Store. It is really simple to use and has a great interface to setup the connection to the database and to browse to the information you need.