CQL console
The Cassandra Query Language Shell (CQLSH) is a command line shell for interacting with your database through Cassandra Query Language (CQL). This tool provides a useful interface for accessing the database and issuing CQL commands.
Embedded Astra DB CQL shell
Each =Astra DB database has an embedded CQL shell instance in the Astra Portal:
-
In the Astra Portal navigation menu, click your database, and then click CQL Console to open a CQLSH instance connected to your database.
-
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:
Replace |
Standalone CQL shell
As an alternative to the embedded CQL shell in the Astra Portal, the standalone CQLSH client is a separate, lightweight tool you can use to interact with your database.
-
If you don’t already have one, create an Astra DB database.
-
Install a Python version with TLS support, which includes versions 2.7.12 or later. For more information, see this DataStax Support article.
-
Download your database’s Secure Connect Bundle (SCB).
-
Generate an application token for your database.
-
Download CQLSH. Choose the latest version for Astra DB.
-
In the directory where you downloaded the CQLSH tarball, extract it:
tar -xvf cqlsh-astra-RELEASE_DATE-bin.tar.gz
Replace
RELEASE_DATE
with the date that the tarball was released, such as20210304
. -
cd
into thecqlsh-astra
directory, and then run thecqlsh
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
andCLIENT_SECRET
: Either of the following sets of values from your application token:-
The
clientId
value and thesecret
value -
The literal string
token
and the token secret, prefixed byAstraCS:
-
(Optional) Store credentials in the
cqlshrc
fileIf you don’t want to pass the credentials on the command line every time, you can configure the location in your
cqlshrc
file:-
In the
~/.cassandra
directory, open thecqlshrc
file. -
In the
[authentication]
section, add theCLIENT_ID
andCLIENT_SECRET
values from your application token. -
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 -
-
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>
-
Select a keyspace in your database:
USE KEYSPACE_NAME;
-
Issue any required CQL commands to create tables, insert data, and manage database resources within the selected keyspace.