Install the CQL shell
The CQL shell (cqlsh) is a Python-based command-line shell you can use to issue Cassandra Query Language (CQL) statements to your DataStax Enterprise (DSE) databases.
The CQL shell also provides unique cqlsh commands like DESCRIBE KEYSPACE.
There are several ways to access the CQL shell, depending on your environment:
| Environment | CQL shell | Notes |
|---|---|---|
DSE tarball installation |
A supported Python version is required. |
|
DSE package installation |
Download and install a CQL shell binary: |
A supported Python version is required. |
DSE not installed |
Download and install a CQL shell binary: |
A supported Python version is required. |
DSE Docker container |
A supported Python version is required. |
Install Python
CQL shell requires Python.
DataStax recommends version 3.8 to 3.11. Later Python versions aren’t supported by DSE 5.1.
Use earlier versions (2.7, 3.6, or 3.7) only if required to support a legacy deployment running an early patch release of DSE 5.1 where your OS or the included cqlsh binary doesn’t support a recommended Python version.
If you have multiple Python versions installed, run cqlsh in a virtual environment that uses a supported Python version.
To verify your Python version, run python -V.
Early CentOS versions requiring Python 2.7
If you are running DSE 5.1 on an early CentOS version that requires Python 2.7, install it from the Software Collections (SCL) Repository:
-
Run the following commands:
sudo yum updatesudo yum install scl-utilssudo yum install centos-release-scl-rhsudo yum install python27sudo scl enable python27 bash -
Check your Python version to confirm that it is 2.7.
-
Restart the system, or log out and log back in, and then enable Python 2.7:
sudo scl enable python27 bashEnabling Python 2.7 in
.bash_profileor.bashrccauses the machine to hang because CentOS 6 relies on Python 2.6 for Yum.
Install the standalone CQL shell for DSE 5.1.51 or later
To install the standalone CQL shell tool, you need a cqlsh binary tarball file.
These files are available from IBM Fix Central in the DSE fix packs for each DSE version.
Download the DSE fix pack for your current DSE version, and then extract the cqlsh distribution:
-
Find DSE fix packs on IBM Fix Central:
-
Go to Fix Central.
-
In the Product selector field, begin typing
IBM DataStax Enterprise, and then select that option from the menu. -
In the Release field, select the version that you want to install.
-
Click Continue.
-
On the Identify fixes page, click Continue to use the default Browse for fixes option.
-
On the Select fixes page, select the fix pack (DSE version) you want to install, and then click Continue.
Depending on the product and version, more fix packs might be available if you set the Platform filter to All, and then click Submit.
-
If prompted, sign in with your IBMid.
An IBMid account with MFA enabled is required. If you don’t have one, create an IBMid account. If your organization uses Enterprise Federation (EF) for authentication with corporate credentials, see the IBMid EF documentation.
-
On the Download options page, select Download using your browser (HTTPS), and then click Continue.
-
Review the terms and conditions, and then click I agree to activate the download links.
-
-
Click the appropriate
dse-VERSION-tgz.ziplink to download the fix pack for your DSE patch release version. -
Wait for the fix pack to download, and then unzip the downloaded file:
unzip dse-VERSION-tgz.zip -
Change to the unzipped directory:
cd dse-VERSION-tgz -
Extract the
cqlshdistribution into the directory where you want to installcqlsh:tar -xzvf cqlsh-VERSION-bin.tar.gz -C /PATH/TO/INSTALL/DIRECTORY
Install the standalone CQL shell for DSE 5.1.50 or earlier
To install the standalone CQL shell tool, you need a cqlsh binary tarball file.
These files are available from IBM Fix Central in the DSE fix packs for each DSE version.
Find the DSE fix pack for your current DSE version, download the cqlsh binary tarball from that fix pack, and then extract the distribution:
-
Find DSE fix packs on IBM Fix Central:
-
Go to Fix Central.
-
In the Product selector field, begin typing
IBM DataStax Enterprise, and then select that option from the menu. -
In the Release field, select the version that you want to install.
-
Click Continue.
-
On the Identify fixes page, click Continue to use the default Browse for fixes option.
-
On the Select fixes page, select the fix pack (DSE version) you want to install, and then click Continue.
Depending on the product and version, more fix packs might be available if you set the Platform filter to All, and then click Submit.
-
If prompted, sign in with your IBMid.
An IBMid account with MFA enabled is required. If you don’t have one, create an IBMid account. If your organization uses Enterprise Federation (EF) for authentication with corporate credentials, see the IBMid EF documentation.
-
On the Download options page, select Download using your browser (HTTPS), and then click Continue.
-
Review the terms and conditions, and then click I agree to activate the download links.
-
-
Click the
cqlsh-VERSION-bin.tar.gzlink to download thecqlshbinary tarball.The version number depends on your fix pack version.
-
Wait for the file to downloaded, and then extract the distribution into the directory where you want to install
cqlsh:tar -xzvf cqlsh-VERSION-bin.tar.gz -C /PATH/TO/INSTALL/DIRECTORY
Use the tarball-bundled CQL shell
If you installed DSE from a tarball, you can find cqlsh in the bin directory of your DSE installation directory.
Make sure you have a supported Python version.
Use the Docker-bundled CQL shell
If you are running a DSE Docker container, you can run the cqlsh script inside the container.
This script is located in DSE_INSTALL_DIRECTORY/bin/.
You can also start CQL shell with docker exec.
For an example, see Attach to a container.