Tuesday, December 22, 2020

redirect query result from psql to LibreOffice Calc by using clipboard

psql as classic TUI application doesn't support clipboard. But it isn't hard to redirect result to clipboard in good format for LibreOffice. First You need an psql from PostgreSQL 13 release. Next you need some clipboard manager application like xclip (XWindows) or pbcopy (MacOS) or wl-clipboard (Wayland). After some testing I found so LibreOffice Calc reads tsv format without problems (for numbers and texts without tabs). It uses identification application/x-libreoffice-tsvc for this format.
postgres=> select * from obce  \g (format=csv tuples_only=off csv_fieldsep='\t') | wl-copy -t application/x-libreoffice-tsvc
And now, the content of table obce is in clipboard and it can be pasted to calc without problems.


At January 12, 2021 at 5:22 AM , Blogger Unknown said...

Great ! In one line of code, one learns a lot !

At January 12, 2021 at 5:23 AM , Blogger Unknown said...

Great ! In one line of code, ones learns a lot


Post a Comment

Subscribe to Post Comments [Atom]

<< Home