Connect to Cassandra from Scala, for dml operations Datastax drivers could be better.
5 minutes reading
I wrote an article a few months ago referring to drivers for connect to Cassandra in a Scala Ecosystem. I’ve created the code and left it on Github so that you can access and download it. So today before to start to write a second part of it I am googling on “scala driver for cassandra” and once again the same results.
I have created a Proof of Concept in depth implementing some basic DM(Data Manipulation) statement.
In this PoC I have created a wrapper of DataStax drivers in which I implement following DM operations:
I have created a template that show you how to implement a platform for DMLs statements (I am NOT talking about DDL). It is completly generic so it will give you a pattern if you want to add more DML operations (Delete,Update).
Our mission is that everything be optimal and simple at the same time. The only point that will increase the complexity depend on your data model. Even so in my PoC I use a model of medium complexity and its solution is very easy.
I have left the code in https://github.com/ldipotetjob/scalacassandra
I think it does not make sense to implement a DDL from Scala. It is more efficient through scripts that can be invoked from processes in Sbt, something that I will detail well in future articles also or even from cassandra REPL: cqlsh
Finally something that we should not forget referring to the aforementioned code: a great advantage in the functional programming is the use of functions that facilitate the TDD. If a test case is complex, it is not useful, if we have to follow a complex logic of programming for implement a test unit, IT WON’T BE USEFUL.