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.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