Vineet Singla
Vineet Singla

Reputation: 1677

Executing multiple cassandra scripts on same keyspace

To execute a single cassandra sript through cqlsh, I am executing the below script and it is working just fine :

cqlsh -k mykeyspace -u username -p password  -f file1.cql

But , I have multiple cqlfiles , So I created a master cql file with entries like

master.cql 
 --Content
source file1.cql
source files.cql
source file3.cql

When executing the above script :

cqlsh -k mykeyspace -u username -p password  -f master.cql

I am getting an error message like "No Keyspace has been specified". I don't want to hardcode the keyspace in the individual cql file. What is the way to execute multiple cql files at once ?

Upvotes: 1

Views: 2310

Answers (1)

undefined_variable
undefined_variable

Reputation: 6218

-f switch allows only single file as of cassandra 3.0.

To run multiple files using cql shell you can create a shell file in linux and execute it.

Example:

You can create a shell file below and run it.

cqlsh -k mykeyspace -u username -p password  -f file1.cql
cqlsh -k mykeyspace -u username -p password  -f file2.cql
cqlsh -k mykeyspace -u username -p password  -f file3.cql

so instead of master.cql master.sh with above commands should do the trick.

Upvotes: 3

Related Questions