Illustration Image

7/2/2022

Reading time:2

Apache Cassandra Lunch #77: Connect to DataStax Astra via Standalone CQLSH - Business Platform Team

logo

This resource is based on an article originally published here.

In Cassandra Lunch #77, we show you how you can connect to your DataStax Astra database using standalone CQLSH. The live recording of Cassandra Lunch, which includes a more in-depth discussion and a demo, is embedded below in case you were not able to attend live. If you would like to attend Apache Cassandra Lunch live, it is hosted every Wednesday at 12 PM EST. Register here now!

In Cassandra Lunch #77, we show you how you can connect to your DataStax Astra database using standalone CQLSH using Gitpod! If you are not familiar with the DataStax CQLSH shell, it is a command-line shell for remotely interacting with your database through CQL. It can be downloadedhere! The CQLSH shell requires Python 2.7 and it connects to 127.0.0.1 9042 by default. However, you can optionally specify the IP address and port to interface with a remote DataStax database, like in our case. Since we are using DataStax Astra, we will need to create a database, and create a token, which generated a client id, client secret, and download the secure connect bundle.

In the walkthrough below, we will spin up this GitHub repo on Gitpod. You can also spin up the repo on Gitpod, but hitting the button the README.md!

If you want to watch the live recording of the demo, you can watch the video embedded below. Otherwise, you can try your own hand at this using the instructions below! We’ve also added some next actions to further extend the tutorial aspect of this Data Engineer’s Lunch, so if you have any other suggestions, feel free to create a GitHub issue!

Method 1

In method 1, we will use a bash script

1. Answer Prompts in Terminal

The startup.sh script either uses stored credentials from the creds.config file or prompts you to insert them in via the command line. If prompted to input credentials, then they will get saved to creds.config, so you do not have to do it repeatedly.

Method 2

In method 2, we will use cqlshrc. This is currently a manual method since Gitpod does not currently persist the ~/ directory upon workspace restart. A bash script for this is in the works.

1. Update cqlshrc file with credentials stored in creds.config

1.1

bash cqlshrc.sh

1.2

sudo mkdir -p ~/.cassandra

1.3

mv cqlshrc ~/.cassandra

1.4

./cqlsh-astra/bin/cqlsh

Next Actions

  • Add ability to read from ENV vars
  • Improve process for cqlshrc method
  • Pivot to connect to Scylla Cloud, AWS Keyspaces, Azure Cosmos DB, etc

If you missed Apache Cassandra Lunch #77: Connect to DataStax Astra via Standalone CQLSH, it is embedded below! Additionally, all of our live events can be rewatched on our YouTube channel, so be sure to subscribe and turn on your notifications!

Don’t forget to check our other Cassandra Lunch topics here!

Cassandra.Link

Cassandra.Link is a knowledge base that we created for all things Apache Cassandra. Our goal with Cassandra.Link was to not only fill the gap of Planet Cassandra but to bring the Cassandra community together. Feel free to reach out if you wish to collaborate with us on this project in any capacity.

We are a technology company that specializes in building business platforms. If you have any questions about the tools discussed in this post or about any of our services, feel free to send us an email!

Related Articles

logo
datastax
cassandra
langchain

Explore Further

cqlsh

cassandra.lunch

cassandra

Become part of our
growing community!
Welcome to Planet Cassandra, a community for Apache Cassandra®! We're a passionate and dedicated group of users, developers, and enthusiasts who are working together to make Cassandra the best it can be. Whether you're just getting started with Cassandra or you're an experienced user, there's a place for you in our community.
A dinosaur
Planet Cassandra is a service for the Apache Cassandra® user community to share with each other. From tutorials and guides, to discussions and updates, we're here to help you get the most out of Cassandra. Connect with us and become part of our growing community today.
© 2009-2023 The Apache Software Foundation under the terms of the Apache License 2.0. Apache, the Apache feather logo, Apache Cassandra, Cassandra, and the Cassandra logo, are either registered trademarks or trademarks of The Apache Software Foundation.

Get Involved with Planet Cassandra!

We believe that the power of the Planet Cassandra community lies in the contributions of its members. Do you have content, articles, videos, or use cases you want to share with the world?