Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use SQLAlchemy with Cassandra CQL?

I use Python with SQLAlchemy for some relational tables. For the storage of some larger data-structures I use Cassandra. I'd prefer to use just one technology (cassandra) instead of two (cassandra and PostgreSQL). Is it possible to store the relational data in cassandra as well?

like image 897
AME Avatar asked Sep 06 '12 10:09

AME


2 Answers

No, Cassandra is a NoSQL storage system, and doesn't support fundamental SQL semantics like joins, let alone SQL queries. SQLAlchemy works exclusively with SQL statements. CQL is only SQL-like, not actual SQL itself.

To quote from the Cassandra CQL documentation:

Although CQL has many similarities to SQL, there are some fundamental differences. For example, CQL is adapted to the Cassandra data model and architecture so there is still no allowance for SQL-like operations such as JOINs or range queries over rows on clusters that use the random partitioner.

You are of course free to store all your data in Casandra, but that means you have to re-think how you store that data and find it again. You cannot use SQLAlchemy to map that data into Python Objects.

like image 200
Martijn Pieters Avatar answered Sep 28 '22 21:09

Martijn Pieters


As mentioned, Cassandra does not support JOIN by design. Use Pycassa mapping instead: http://pycassa.github.com/pycassa/api/pycassa/columnfamilymap.html

like image 40
jbellis Avatar answered Sep 28 '22 23:09

jbellis