CQL for Python without any additional abstraction layers. Designed to be simple and fast tool for communication with Cassandra. CQLSL is something between native Cassandra driver (which is really awesome!) and ORM.
First of all: not all applications need to use ORM. Second reason: I hate ORMs that use Active Record Pattern. Especially, when they try to be similar to Django ORM syntax. Usually, we lost a lot of useful features of chosen storage, when we try to build own abstraction layer on top of it.
pip install cqlsl
First of all you need to define connection settings to your Cassandra cluster (For advanced configuration, please, read official documentation for python cassandra driver):
from cassandra.cluster import Cluster
cluster = Cluster(['localhost'])
Then you need to define session with this cluster:
from cqlsl.sessions import Session
session = Session(cluster, keyspace='myapp')
And you ready to perform queries:
from cqlsl.statements import *
session.execute(
insert('books').values(id=1, title='Domain-driven Design', author='Eric Evans', year=2004)
)
session.execute(
update('books').set(title='Domain-driven Design: Tackling Complexity...').where(id=1)
)
book_title = session.execute(
select('books').fields('title').where(id=1)
)[0]['title']
session.execute(
delete('books').fields('year').where(id=1)
)
Under construction...
Under construction...
- #5 Add Python 3.4.x support (@mantzouratos @drudim)