postgresql-pretty-table
postgresql-pretty-table copied to clipboard
A small script to make pretty html tables from psql
A small script to make pretty html tables from psql
Installation
Put the shell script in PATH. On OS X, brew install gnu-sed.
On Linux, change references to gsed to sed and open -a Safari to
xdg-open or firefox equivalent.
Usage
- In psql,
\H -- html mode
\o test.html
select * from mytable; -- or any other query.
\o -- so that it no longer prints to file
\H -- disable html mode
- In shell,
make_pretty_table.sh test.html
or even better, while staying in psql
\! make_pretty_table.sh test.html
This will create a file test_enhanced.html and open it in a web browser.
Example
To get all tables in the system in html,
In postgres,
\H -- html mode
\o test.html
\dt+
\o
\! make_pretty_table test.html
