Reputation: 15988
I'm trying to create a small shell script where it would be very handy for me to run a command directly from the command line via cqlsh.
In MySQL I could do something like:
mysql -u root -e "show databases;"
Is there a cqlsh equivalent to -e
, or is the closest equivalent putting whatever commands I want to run in a file and use -f
?
Thanks
Upvotes: 5
Views: 2510
Reputation: 57843
For just a one-shot command, cqlsh
4.1.1 also has a -e
option:
$cqlsh -e 'desc keyspaces' -u myusername -p mypassword localhost
branch stackoverflow products system_auth
customers system branches system_traces
If you have something complicated, like a multi-line sequence of commands, then the -f
option on cqlsh
should be what you want to do. To demo, I'll create a simple cql script file called descTables.cql
which looks like this:
$ cat descTables.cql
use stackoverflow;
desc tables;
Now, I'll invoke that cql script with cqlsh -f
:
$cqlsh -f descTables.cql -u myusername -p mypassword localhost
datasimple items
FYI- It looks like the most-recent version of 2.0 has cqlsh
4.1.1, which has the -e
flag. On one of my instances, I have 4.1.0 and the -e
option is not available.
Upvotes: 5
Reputation: 709
There are more options they are listed below:
Upvotes: 0