Pavel Stehule: redirect result from psql to libreoffice calc

Sometimes can be useful to forward output query result from console to spreadsheet. Unfortunately, it is not trivial task, but it is not pretty hard too.

I have a table “obce” (It is “municipality” in Czech language), and I would to see the content of this table in spreadsheet. Then I can redirect output in csv format to libreoffice. But first I need to have named pipe:


mknod p pipe

Now I can run psql and write command:


postgres=# select * from obce g (format=csv) | cat > pipe; libreoffice --view --calc pipe "--infilter='Text - txt - csv (StarCalc)':44,34,0,1"

The psql from Postgres 13 is required.

PostgreSQL