user1157751
user1157751

Reputation: 2457

Cassandra and Python Driver - Getting Duplicate Rows

I'm trying to use the Cassandra and Python driver to get data out of a Cassandra database.

This is my cql command to generate a table, and keyspace:

CREATE KEYSPACE regression WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1};

USE regression;

CREATE TABLE results (
uuid text,
jobname text,
date text,
block text,
results text,
metrics text,
PRIMARY KEY ((uuid), jobname, date, block));

When I open cql, and type in select block from results, I get the following:

 block
------------------------
            simple_buff
 simple_buff_pre_commit

However, when I do the same thing in python:

from cassandra.policies import RetryPolicy
cluster = Cluster(
  contact_points=['127.0.0.1'],
   default_retry_policy = RetryPolicy()
  )
session = cluster.connect('regression')
results = session.execute("select block from results")
for result in results:
    print results
    print "END"

It gives me:

[Row(block=u'simple_buff'), Row(block=u'simple_buff_pre_commit')]
END
[Row(block=u'simple_buff'), Row(block=u'simple_buff_pre_commit')]
END

Why does it returns a Row with two item compared to cql client which only returns me two rows with one item? If I do select * from results in python, it will give me two copies of the same row twice.

Upvotes: 0

Views: 170

Answers (1)

rodolk
rodolk

Reputation: 5907

Because of this line:

print results

It should be result without 's'

print result

Upvotes: 1

Related Questions