August 22nd, 2014






Rafał Furmański Python Developer at Opera Software International


Django cassandra engine is a simple database wrapper for Django, providing very easy way to connect and interact with a Cassandra database, like every Django developer is used to. It uses cqlengine which is currently the best Cassandra Object Mapper for Python.
Basically my backend is everything you need to start using Cassandra and Django together.


Django + Cassandra
Django is the most mature and popular web framework for Python, with a great community and huge amount of pluggable apps and extensions. I was almost always able to find an interesting package on the Internet. The first thing I did when I found out that we’ll be using Cassandra in our new project was to search for an appropriate database backend for Django. I was really surprised that there were none, so I decided to write it on my own, with a goal  to make it very simple and easy to use. After some research about available Python clients I decided to use cqlengine over Pycassa and the official DataStax Python driver. Mainly because Pycassa does not support CQL, and cqlengine is very actively developed at the time. 


NoSQL databases don’t have official support for Django, and I think that’s not good, because they’re very popular and widely used these days. There are projects like django-nonrel that tries to fill this gap and add support for MongoDB or Google App Engine. In my opinion Cassandra is a great database and requires at least basic support for Django, too. My wrapper is an answer for that, and will be soon battle-tested.


Learning Cassandra
I have only a few months experience with Cassandra and I know that there is probably a long road ahead of me to know it better. We’re about to launch two big projects in the very near future so I hope to experience its outstanding performance and high availability. What I can say after these couple months time is that Cassandra is fairly easy to learn and deploy. It comes with great management and monitoring tool called OpsCenter that I like a lot!


Starting with the engine
First you have to install it, preferably using pip (pip install django-cassandra-engine). Then add ‘django_cassandra_engine’ to INSTALLED_APPS in and configure DATABASES setting as you’re used to. After that define some models, run ‘syncdb’ management command and you’re done! Everything is well documented on wrappers’ site as well as cqlengine.


If you would like to see a “must have” feature or find any bug in my wrapper just contact me – I’ll try to implement or fix it as soon as possible.  I would try to encourage all of you to learn Cassandra and don’t be afraid to use it, especially in Python and Django.