3
votes

Intro I'm using the python cql library library to access a Cassandra 1.2 database (CQL 3.0). My table contains a boolean column as follows:

CREATE TABLE test (
     id         text,
     value      boolean,
     PRIMARY KEY (id)
);

The problem When I try to execute a query like this one using the cql library:

UPDATE test set value=True where id = 'someid'

And using this code:

import cql
...
cql_statement = "UPDATE test set value=:value where id = :id"
rename_dict = {'id':'someid', 
               'value': True}
cursor.execute(cql_statement, rename_dict)

I'm getting this error:

Bad Request: Invalid STRING constant (True) for value of type boolean

Seems like the cql library is trying to execute this:

UPDATE test set value='True' where id = 'someid'

Instead of this:

UPDATE test set value=True where id = 'someid'

The question

Is there any workaround for this or better way/library to use? (I'm using Cassandra 1.2 with CQL 3.0 CFs, so pycassa is not an option)

Thanks in advance!

1
Your ID type should be an integer rather than a string. Also, are you using CQL driver version 1.0.4 that you link to, or the latest (1.4.0)? - Richard
Hi Richard, I'm using the latest (1.4.0). Can you elaborate about not using a string as a key please? - Sergio Ayestarán
id is an int in your table definition but you are setting it to the string 'someid'. - Richard
Thank you so much Richard, I edited the question to fix it! - Sergio Ayestarán

1 Answers

3
votes

Boolean quoting has been fixed in the upstream since this question was asked, though Debian packages are not updated yet.

Thus solution is to install the library from source.