Cassandra DB

Chaayagirimon
featurepreneur
Published in
2 min readMar 19, 2022

pulling cassandra from docker:

docker run \
--name cassandra \
-p 7000:7000 \
-p 9042:9042 \
-v clocal:/bitnami \
-d bitnami/cassandra:latest

create a container:

to run command in a container:

docker exec -it cassandra bash

access the cassandra DB:

/opt/bitnami/cassandra/bin/cqlsh -u cassandra -p cassandra

Create a keyspace:

CREATE KEYSPACE IF NOT EXISTS memeWITH REPLICATION = {'class' : 'SimpleStrategy','replication_factor' : 1};use meme;

Check if the table already exists:

DROP TABLE IF EXISTS meme.vmeme;

Then create a table:

CREATE TABLE meme.vmeme (
id int PRIMARY KEY,
movie_name text,
dialogue text,
);

Insert records into the table:

INSERT INTO meme.vmeme (id, movie_name, dialogue) VALUES(1, 'Winner', 'Athu pona maasam ,naan sonnathu entha maasam.');INSERT INTO meme.vmeme (id, movie_name, dialogue) VALUES(2, 'Thailainagaram', 'Yey.Enna vechu comedy geemedy oonum pannaliye!');INSERT INTO meme.vmeme (id, movie_name, dialogue) VALUES(3, 'Friends', 'Anniyae pudunga vaenam');

Displaying all the records of the table:

SELECT * from meme.vmeme;

--

--