Connect to the CQL shell
The Cassandra Query Language Shell (cqlsh
) is a utility that you can use to issue CQL commands to your Astra DB Serverless database.
You can use the embedded CQL shell in the Astra Portal or the standalone CQL shell.
You can use the Astra CLI to download and configure the CQL shell, including the Secure Connect Bundle (SCB) and set up the token for your Astra DB Serverless account.
For more information, see the Use |
Embedded CQL shell
The Astra Portal provides an embedded CQL shell instance, known as the CQL Console, for each Astra DB Serverless database.
-
In the Astra Portal navigation menu, select your database.
-
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 CQL shell client is a separate, lightweight utility that you can use to interact with your database.
To install and use the standalone CQL shell, you need Python version 2.7.12+ with TLS Support and the SCB for your database.
-
Download the CQL shell for your Astra DB Serverless database:
-
DataStax Astra
-
DataStax Astra with support for Vector Type.
-
-
Change to the directory where you downloaded the CQL shell package:
$ cd /DOWNLOAD_DIRECTORY
-
Extract the files:
$ tar -xvf cqlsh-astra-DATE-bin.tar.gz
Replace
date
with the package release date, such as20210304
. -
Run the
cqlsh
script:$ cd /cqlsh-astra $ ./bin/cqlsh -u CLIENT_ID -p CLIENT_SECRET -b PATH_TO_SCB
Specify the following arguments:
-
-b
: The path to your database’s SCB (secure-connect-DATABASE_NAME.zip
). -
-u
and-p
: Authentication credentials to connect to your database. Either aCLIENT_ID
andCLIENT_SECRET
or the literal stringtoken
and an application token prefixed byAstraCS:
. For more information, see Manage application tokens.If you do not want to pass the SCB on the command line every time, set the location in your
cqlshrc
file.In the
[authentication]
section of thecqlshrc
file in~/.cassandra
, include theCLIENT_ID
andCLIENT_SECRET
from your application token. Configure the[connection]
section of thecqlshrc
file in~/.cassandra
to include the path to your SCB:[authentication] username = CLIENT_ID password = CLIENT_SECRET [connection] secure_connect_bundle = /SECURE_CONNECT_BUNDLE_PATH/secure-connect-DATABASE_NAME.zip
A result such as the following indicates that the CQL shell is connected to your database:
[cqlsh 6.8.0 | DSE 6.8.0.77 | CQL spec 3.4.5 | DSE protocol v2] Use HELP for help. username@cqlsh>
-
-
To manage data, select the keyspace that you want to work in:
use KEYSPACE_NAME;
From here, you can issue any supported CQL commands to create tables, insert data, update data, and more. For more information, see Cassandra Query Language (CQL) for Astra DB quickstart and CQL reference.