Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python cql library not able to update a boolean column using query substitution

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!

like image 478
Sergio Ayestarán Avatar asked May 16 '26 12:05

Sergio Ayestarán


1 Answers

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.

like image 98
Pavel Kirienko Avatar answered May 18 '26 01:05

Pavel Kirienko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!