Disable Psql Output Wrapper

When using Psql on Linux, if the result of my SQL query contains many columns or long rows of data, it will wrap the initial view, and only once when I go sideways, it will stop wrapping and show each row on a separate line.

I tried various \pset options , such as format unaligned , format aligned , format wrapped , columns 0 , columns 1000 , but no one seemed to stop the wrapper completely if I did not create static output to the file.

How can I set it to never finish the output while it is still scrolling, and showing the result using the default ascii table format?

+5
source share
4 answers

Psql uses the system viewer to display its output in the console. In bash it most likely uses less for scrollable / page-accessible functions. To use a different viewer or use different settings, you just need to set the PAGER environment PAGER .

Running Psql to use less with the -S or --chop-long-lines option seemed to work for me:

 PAGER="less -SF" psql 
+14
source

To disable the final output of a select request.

\ pset pager as well as \ pset pager to return to an earlier view of the output.

+2
source
Flag

less than -F or -S will cause \d some_table not output any output in some cases.

 -F or --quit-if-one-screen Causes less to automatically exit if the entire file can be displayed on the first screen. -S or --chop-long-lines Causes lines longer than the screen width to be chopped rather than folded. That is, the portion of a long line that does not fit in the screen width is not shown. The default is to fold long lines; that is, display the remainder on the next line. 

Use them as follows:

 PAGER="less -S" psql 

It seems safer if you have the inconvenience of having to manually exit less.

+1
source

You should probably use the aligned format to output:

 \pset format aligned 

You can check all available formats according to your needs:

 \pset format TAB aligned html latex-longtable unaligned asciidoc latex troff-ms wrapped 

You should also check the PAGER configured value in your environment.

0
source

Source: https://habr.com/ru/post/1257688/


All Articles