Skip to content

This yml and docker file setup help us understand establishing connection between a Linux-container and Cassandra dbms container

Notifications You must be signed in to change notification settings

pawanxcaliber/Linux_container-to-Cassandra_container-connection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cassandra and Python Containers Connection

==============================================

Overview


This project demonstrates a simple DevOps setup using Docker containers. It consists of two main components:

  • A Cassandra database container
  • A Python application container that interacts with the Cassandra database

Prerequisites


  • Docker installed on your system
  • Docker Compose installed on your system

Getting Started


Step 1: Clone the Repository

git clone https://github.com/your-username/your-repo-name.git

Step 2: Build and Start the Containers

Build the Docker images:

docker-compose build

Start the containers:

docker-compose up 

Step 3: Verify the Containers

Check the status of the containers:

docker-compose ps -a

This should display both the Cassandra and Python containers running.

Cassandra Database


Accessing the Cassandra Database Enter the Cassandra container:

sudo docker-compose exec cassandra bash

Start the CQLSH tool:

cqlsh

Switch to the mykeyspace keyspace:

USE mykeyspace;

Run a SELECT query to retrieve the data:

SELECT * FROM mytable;

This should display the data you inserted earlier:

 id | name
----+----------
  1 | John Doe
  2 | Jane Doe

You can exit the cqlsh tool by typing EXIT or QUIT.

Alternatively, you can also use the cqlsh command with the -e option to execute a query directly:

cqlsh -e "SELECT * FROM mykeyspace.mytable;"

This should display the data.

Python Application


Overview

The Python application container interacts with the Cassandra database. It uses the cassandra-driver library to connect to the Cassandra database. Code The Python code is located in the python directory. It consists of a simple script that connects to the Cassandra database and inserts some sample data.

About

This yml and docker file setup help us understand establishing connection between a Linux-container and Cassandra dbms container

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published