Is there a way to display results in a pager in Cassandra cqlsh?
Asked Answered
B

1

8

If the output of a query cannot be properly displayed within the dimensions of the terminal used to issue the query, the ASCII-art used to draw the table layout usually breaks and becomes a more of a hinderance than a help when trying to read the displayed results.

This also happens a lot when using Cassandra's cqlsh. Although there is the option EXPAND ON to display the results in a line based layout, I would rather like to configure cqlsh in a way, so that table output that is too big for the terminal, is automatically piped into a pager.

In PostgreSQL's psql utitliy, the pager configured in the environment variable PAGER is automatically used as soon as the output doesn't fit into the terminal. Usually the less command is used as pager. In MySQL you can use a command like PAGER less to display all results through a the pager less.

Is there a comparable feature available in cqlsh?

Bitternut answered 16/12, 2015 at 8:6 Comment(0)
E
4

If you want you can capture the output to a file and then run the file through a pager.

e.g run this command on cqlsh shell

CAPTURE '~/out.txt'

Now when you run any select command, the output is written to that file instead showing you in the terminal. you can page the file(out.txt) using less or more.

Here is the documentation : http://docs.datastax.com/en/cql/3.1/cql/cql_reference/capture_r.html

Also there is paging option in cqlsh. run the following command to see if its enabled or not

paging

run following to enable it

paging on

however it still displays 100 rows before it start paging. I am not sure if there is a way to configure paging to start paging as soon as the output goes more then one screen.

Erlanger answered 11/11, 2016 at 16:25 Comment(1)
You can set the number or rows via the same command, as stated in the docs. PAGING [ ON | OFF ] ( page_size )Flapper

© 2022 - 2024 — McMap. All rights reserved.