Connect to the CQL shell for Astra DB
To run CQL statements against your Astra DB Serverless databases, you can use the CQL shell (cqlsh), a Cassandra driver, or the Data API.
This guide explains how to use the CQL shell (cqlsh) to interact with your Astra DB databases.
For information about other connection methods, see Cassandra Query Language (CQL) for Astra DB.
The CQL shell (cqlsh) is a utility that you can use to issue CQL and cqlsh commands to your Astra DB Serverless databases.
You can use the CQL console in the Astra Portal, or you can install the CQL shell utility with the Astra CLI.
Use the CQL console (embedded CQL shell)
In the Astra Portal, each Astra DB Serverless database has access to the CQL console, which is an embedded CQL shell instance.
You can use the CQL console to run CQL and cqlsh commands on your databases directly from your browser without installing any additional software.
-
In the Astra Portal, click the name of the database that you want to connect to.
-
Click CQL console to open the embedded CQL shell in a new tab.
Your session is automatically authenticated and connected based on the selected database and your assigned role in the Astra Portal.
-
Wait for the
token@cqlsh>prompt to appear.This prompt indicates that CQL shell is connected to your database, and you can start sending CQL and
cqlshcommands to your database. -
Optional: For multi-region databases, use the region menu to access data from a secondary region.
Typically, you change regions only if the primary region is geographically distant from your machine. Due to Astra DB’s eventual consistency model, changes to data in any region are eventually replicated to the database’s other regions.
Alternatively, after you sign in to the Astra Portal, you can directly access the built-in CQL console app at DATABASE_ID-REGION.apps.astra.datastax.com/cqlsh.
The database ID and region set the context for the CQL console session.
If you use custom domains, replace astra.datastax.com with your custom domain.
Use the standalone CQL shell
For remote programmatic access, use the Astra CLI to download, install, and use the standalone CQL shell utility:
-
Connect the Astra CLI to a database.
After you run
astra setupand create a configuration profile, the same connection details and options are used to runastra db cqlshcommands. For example, the application token in your Astra CLI configuration profile is automatically used for the CQL shell--passwordoption. Unless you want to use a different token, you don’t need to explicitly set--passwordfor everyastra db cqlshcommand. -
Run
astra db cqlsh start DB_IDor any otherastra db cqlshcommand.The first time that you run an
astra db cqlshcommand, Astra CLI automatically installs the CQL shell.All
astra db cqlshcommands require a database ID. Manycqlshoptions are inherited from Astra CLI, such as connection details from your Astra CLI configuration profile and output preferences like--color. You can add or override anycqlshoptions by appending them to yourastra db cqlshcommands.For more information and examples, see the Astra CLI CQL shell quickstart.