Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 787
aef Avatar asked Oct 31 '22 13:10

aef


1 Answers

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.

like image 164
root Avatar answered Nov 15 '22 13:11

root