Illustration Image

Cassandra.Link

The best knowledge base on Apache Cassandra®

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

12/12/2019

Reading time:1 min

Using Cassandra with Flask – Rishabh Mehan

by darkrishabh

I was recently working on few things which needed the use of Cassandra. I have only worked with Cassandra on JAVA, which you all might agree(if you have used JAX-RS or made any service on JAVA) is a tedious and bulky task.I have been using Flask for most of my applications, it’s lightweight and it’s easy to develop and deploy quickly on Python.So let’s start with the things we need:Cassandra – you can get the Download and Install directions from Datastax.Python 2.7I work on a Mac so I have 50% of things already installed. And for the IDE I am using PyCharmSo let’s create our Flask app firstmkdir TestCass && cd $_
virtualenv tenv
source tenv/bin/activate
mkdir views && mkdir models
touch TestCass.pyDon’t forget to add __init__.py to views, models, and TestCass directory. It should look like this at the endNow install cassandra-driverpip install cassandra-driverI know no one likes to read so I have uploaded a video on Youtube and pushed the code to github.Youtube – https://www.youtube.com/watch?v=kf51lzxo1LsGithub – https://github.com/darkrishabh/PythonFlaskCassandra

Illustration Image

Python Flask + Cassandra

I was recently working on few things which needed the use of Cassandra. I have only worked with Cassandra on JAVA, which you all might agree(if you have used JAX-RS or made any service on JAVA) is a tedious and bulky task.

I have been using Flask for most of my applications, it’s lightweight and it’s easy to develop and deploy quickly on Python.

So let’s start with the things we need:

  1. Cassandra – you can get the Download and Install directions from Datastax.
  2. Python 2.7

I work on a Mac so I have 50% of things already installed. And for the IDE I am using PyCharm

So let’s create our Flask app first

mkdir TestCass && cd $_
virtualenv tenv
source tenv/bin/activate
mkdir views && mkdir models
touch TestCass.py

Don’t forget to add __init__.py to views, models, and TestCass directory. It should look like this at the end

Now install cassandra-driver

pip install cassandra-driver

I know no one likes to read so I have uploaded a video on Youtube and pushed the code to github.

Youtube – https://www.youtube.com/watch?v=kf51lzxo1Ls

Github – https://github.com/darkrishabh/PythonFlaskCassandra

Related Articles

spring
angular
rest

GitHub - jhipster/jhipster-sample-app-cassandra: This is a sample application created with JHipster, with the Cassandra option

jhipster

3/7/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

rest