An example how I directly connect to Cassandra by CQL (1)

cassandra, cql, django, python

Solution

This is how I made python communicate to cassandra.

First, you need to establish a connection, adding:

import cql
con= cql.connect(host="127.0.0.1",port=9160,keyspace="testKS")

Then generate a cursor for query:

cur=con.cursor()
result=cur.execute("select * from TestCF")

And I can see the result by:

result.fetchone()

or

result.fetch()

This queries nicely and doesn't need extra library, such pycasaa or cqlengine

Problem

I need full example that show me how I can Connect to Cassandra by CQL. I am working on a project that should be written in (python) Django and I want to do some thing directly not only using cqlEngine as my Project Driver. Thanks for your help.

Original source