Connect to the CQL shell

The Cassandra Query Language Shell (CQLSH) is an interface that you can use to issue Cassandra Query Language (CQL) commands to your Astra DB Serverless database. You can use the embedded CQL shell in the Astra Portal or the standalone CQL shell.

If you use the Astra CLI, you can use it to download and configure the CQL shell, including the secure connect bundle, and set up the token for your Astra DB Serverless account. For more, see the Astra CLI documentation.

Embedded CQL shell

Each Astra DB Serverless database includes an embedded CQL shell instance.

  1. Create a database.

  2. In the Astra Portal, go to Databases, and then select your database.

  3. Click CQL Console.

The CQL Console opens in a new window and connects directly to your database. You can now run CQL commands on your database without leaving your browser.

Standalone CQL shell

The standalone CQLSH client is a separate, lightweight tool you can use to interact with your database.


Install the standalone CQLSH

  1. Download the CQLSH for your Astra DB Serverless database. Select the CQLSH for DataStax Astra or DataStax Astra with support for Vector Type.

  2. Change to the directory with the downloaded CQLSH tarball.

  3. Extract the files from the tarball.

    $ tar -xvf cqlsh-astra-DATE-bin.tar.gz


    The date that the tarball was released, such as 20210304.

  4. Run the cqlsh script from the command line:

    $ cd /cqlsh-astra

    Use the -b option to specify the location of the secure connect bundle for your database. Pass the CLIENT_ID and CLIENT_SECRET for your database role using the -u and -p options. For more, see Manage application tokens.


    Client ID for the database role.


    Client secret for the specified Client ID.


    Name of the Astra DB database to which you want to connect. Include the absolute path to the secure connect bundle for the database, such as '/Users/myuser/Downloads/'.

    Configure the cqlshrc file

    If you do not want to pass the secure connect bundle on the command line every time, set the location in your cqlshrc file.

    In the [authentication] section of the cqlshrc file in ~/.cassandra, include the CLIENT_ID and CLIENT_SECRET from your application token. Configure the [connection] section of the cqlshrc file in ~/.cassandra to include the path to your secure connect bundle:

    username = CLIENT_ID
    password = CLIENT_SECRET
    secure_connect_bundle = /SECURE_CONNECT_BUNDLE_PATH/

    You are connected to your database using CQLSH.

    [cqlsh 6.8.0 | DSE | CQL spec 3.4.5 | DSE protocol v2]
    Use HELP for help.
  5. Switch to your keyspace, where you can issue CQL commands to create tables, insert data, and manage database resources:


What’s next?

You can now query your database using CQL commands. For more, see Cassandra Query Language (CQL) quickstart and the CQL reference.

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,