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.
Each Astra DB Serverless database includes an embedded CQL shell instance.
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.
The standalone CQLSH client is a separate, lightweight tool you can use to interact with your database.
Download the CQLSH for your Astra DB Serverless database. Select the CQLSH for DataStax Astra or DataStax Astra with support for Vector Type.
Change to the directory with the downloaded CQLSH tarball.
$ cd /DOWNLOAD_DIRECTORY
Extract the files from the tarball.
$ tar -xvf cqlsh-astra-DATE-bin.tar.gz
The date that the tarball was released, such as 20210304.
Run the cqlsh script from the command line:
$ cd /cqlsh-astra $ ./bin/cqlsh -u CLIENT_ID -p CLIENT_SECRET -b /SECURE_CONNECT_BUNDLE_PATH/secure-connect-DATABASE_NAME.zip
-boption to specify the location of the secure connect bundle for your database. Pass the
CLIENT_SECRETfor your database role using the
-poptions. 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/secure-connect-database123.zip'.
If you do not want to pass the secure connect bundle on the command line every time, set the location in your
[authentication]section of the
~/.cassandra, include the
CLIENT_SECRETfrom your application token. Configure the
[connection]section of the
~/.cassandrato include the path to your secure connect bundle:
[authentication,subs="verbatim,quotes"] username = CLIENT_ID password = CLIENT_SECRET [connection] secure_connect_bundle = /SECURE_CONNECT_BUNDLE_PATH/secure-connect-DATABASE_NAME.zip
You are connected to your database using CQLSH.
[cqlsh 6.8.0 | DSE 18.104.22.168 | CQL spec 3.4.5 | DSE protocol v2] Use HELP for help. username@cqlsh>
Switch to your keyspace, where you can issue CQL commands to create tables, insert data, and manage database resources: