Sunday, February 20, 2022

[SOLVED] Redirecting the cassandra shell output to file

Issue

It is a LINUX question,

I have a Cassandra cluster with 6 nodes and I am using the cqlsh. I have enabled the TRACING ON feature , So on any READ / WRITE it prints too much lines of information which actually I need. So I need to redirect all the informations to a file which I perform inside cqlsh.

Could you please help me?


Solution

Inside cqlsh, once the tracing is turned on, you can use the CAPTURE command to redirect the your sql or command output to a file

Example: CAPTURE 'output.txt' -- output of the sql executed after this command gets captured into output.txt file

In case if you would like to redirect the SQL output to a file from outside of cqlsh

./cqlsh -e'select * from keyspaceName.tableName' > fileName.txt -- hostname



Answered By - Gangadhar Kairi
Answer Checked By - Candace Johnson (WPSolving Volunteer)