Search code examples
cassandracqlcassandra-2.0

How to run cql files (.cql) from within cqlsh?


The problem that I am having is that I want to run the following command (and I can't):

cqlsh < cql_directory/cql_create_stuff.cql

Because I have not logged in to cqlsh.

So I logged in:

cqlsh -u 'my_username' -p 'my_super_secret_password'

and now I tried doing the command in cqlsh shell but It just responds with a syntax error.

Basically, how do I login into cqlsh and run an external CQL script in my file system?


Solution

  • Use the SOURCE

    http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/source_r.html

    You can use -f option as well to execute commands from file

    http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/cqlsh.html