Illustration Image

Cassandra.Link

The best knowledge base on Apache Cassandra®

Helping platform leaders, architects, engineers, and operators build scalable real time data platforms.

7/2/2022

Reading time:2 min

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

by Arpan Patel

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 1In method 1, we will use a bash script1. Answer Prompts in TerminalThe 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 2In 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.config1.1bash cqlshrc.sh1.2sudo mkdir -p ~/.cassandra1.3mv cqlshrc ~/.cassandra1.4./cqlsh-astra/bin/cqlshNext ActionsAdd ability to read from ENV varsImprove process for cqlshrc methodPivot to connect to Scylla Cloud, AWS Keyspaces, Azure Cosmos DB, etcIf 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.LinkCassandra.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!Posted in Data & Analytics, Events | Comments Off on Apache Cassandra Lunch #77: Connect to DataStax Astra via Standalone CQLSH

Illustration Image

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

astra
cassandra
datastax.astra

Vector Databases Compared - Evaluating DataStax Astra DB Serverless (Vector) and Pinecone Vector Database

John Doe

2/4/2024

Checkout Planet Cassandra

Claim Your Free Planet Cassandra Contributor T-shirt!

Make your contribution and score a FREE Planet Cassandra Contributor T-Shirt! 
We value our incredible Cassandra community, and we want to express our gratitude by sending an exclusive Planet Cassandra Contributor T-Shirt you can wear with pride.

Join Our Newsletter!

Sign up below to receive email updates and see what's going on with our company

Explore Related Topics

AllKafkaSparkScyllaSStableKubernetesApiGithubGraphQl

Explore Further

cqlsh