CQL Console

You can use the Cassandra Query Language shell (cqlsh) utility to issue CQL commands to your database from the command line.

Embedded Astra DB CQL shell

Each Astra DB database has an embedded CQL shell instance in the Astra Portal:

  1. In the Astra Portal navigation menu, click your database, and then click CQL Console to open a CQL shell instance connected to your database.

  2. Issue CQL commands to your Astra DB database directly in your browser.

To open the CQL Console in a full window, use the following URL:

DATABASE_ID-REGION_NAME.apps.astra.datastax.com/cqlsh

Replace DATABASE_ID and REGION_NAME with your database’s ID and the name of the region where your database is deployed.

Standalone CQL shell

As an alternative to the embedded CQL shell in the Astra Portal, the standalone CQL shell client is a separate, lightweight tool you can use to interact with your database.

  1. If you don’t already have one, create an Astra DB database.

  2. Install a Python version with TLS support, which includes versions 2.7.12 or later. For more information, see this DataStax Support article.

  3. Download your database’s Secure Connect Bundle (SCB).

  4. Generate an application token for your database.

  5. Download CQL shell for Astra DB.

  6. In the directory where you downloaded the CQL package, extract it:

    tar -xvf cqlsh-astra-RELEASE_DATE-bin.tar.gz

    Replace RELEASE_DATE with the package release date, such as 20210304.

  7. In the cqlsh-astra directory, run the cqlsh script:

    cd /cqlsh-astra
    ./bin/cqlsh -u CLIENT_ID -p CLIENT_SECRET -b PATH_TO_SCB

    Replace the following:

    • PATH_TO_SCB: The path to your database’s SCB zip file

    • CLIENT_ID and CLIENT_SECRET: Either of the following sets of values from your application token:

      • The clientId value and the secret value

      • The literal string token and the token secret, prefixed by AstraCS:

    (Optional) Store credentials in the cqlshrc file

    If you don’t want to pass the credentials on the command line every time, you can configure the location in your cqlshrc file:

    1. In the ~/.cassandra directory, open the cqlshrc file.

    2. In the [authentication] section, add the CLIENT_ID and CLIENT_SECRET values from your application token.

    3. In the [connection] section, add the path to the SCB.

    [authentication]
    username = CLIENT_ID # or the literal string token
    password = CLIENT_SECRET # or the token secret prefixed by 'AstraCS:'
    
    [connection]
    secure_connect_bundle = PATH_TO_SCB
  8. Make sure the command returns output indicating that you connected to your database. For example:

    [cqlsh 6.8.0 | DSE 6.8.0.77 | CQL spec 3.4.5 | DSE protocol v2]
    Use HELP for help.
    username@cqlsh>
  9. Select a keyspace in your database:

    USE KEYSPACE_NAME;
  10. Issue any required CQL commands to create tables, insert data, and manage database resources within the selected keyspace.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com