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.
You can use the Astra CLI 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 information, see the Astra CLI documentation. |
Embedded CQL shell
Each Astra DB Serverless database includes an embedded CQL shell instance.
-
In the Astra Portal, go to Databases, and then 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 CQLSH client is a separate, lightweight tool you can use to interact with your database.
Prerequisites
-
Ensure Python version 2.7.12+ with TLS Support is installed. For more details, see this Support article.
-
Download the secure connect bundle for your database.
Install the standalone CQLSH
-
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
Replace
date
with 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
Use the
-b
option to specify the location of the secure connect bundle for your database. Pass theCLIENT_ID
andCLIENT_SECRET
for your database role using the-u
and-p
options. For more, see Manage application tokens.CLIENT_ID
Client ID for the database role.
CLIENT_SECRET
Client secret for the specified Client ID.
database_name
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'.
Configure the
cqlshrc
fileIf 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 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 secure connect bundle:[authentication] 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 6.8.0.77 | 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:
use KEYSPACE_NAME;
You can now query your database using CQL commands.