Running CQL scripts in Cassandra

How to run CQL scripts in Cassandra

 There are 2 ways to run a CQL script, the first way would be running the following command:
- cqlsh -f {directory}

The second way would be using the command within the CQLSH terminal:
- source '{directory}'

Where does the {directory} points to?

The directory points to the root of your server. For example, if you are on linux, the root would be `/`. Therefore, if you placed your scripts under the folder `scripts`, your directory would look like this `/scripts/{cql_script_name}.cql`. 


I've been running the command, but it keeps saying `No such file or directory`?

If you met this error, please make sure that:
    - The file actually exist in the directory. You can check if by typing `ls -l {directory}`. If it doesn't exist, it will show the same error. If you are on docker, and you are unsure of how to mount your CQL file into your container, you can check out this guide.


    - The CQL file has the correct extension name, and the directory must include the extension as well. For example, `/scripts/{cql_script_name}` doesn't work, but `/scripts/{cql_script_name}.cql` does. Also, make sure that while mounting your cql file, the file mounted includes the file extension as well, or else it would be treated as a directory.

Running source {directory} causes Improper source command, how to fix that?

Make sure while running the `source '{directory}'`, the {directory} is wrapped in single quotation, instead of double quotation, or no quotation at all.


Comments

Popular posts from this blog

Support for the experimental syntax 'decorators' isn't currently enabled (5:3):

How to add environment variables into Heroku container