when I want to update a set item in Cassandra table with python code like following
ps = session.prepare( """ UPDATE test,tbl SET val = val + {'?'} where name = ? and id = ?;""" )
bs = bind(ps, ['name', 'name', 1])
session.execute(bs)
I got error
Too many arguments provided to bind() (got 3, expected 2)
the problem is {'?'} that cant identified by prepared. I test {\'?\'} but nothing change.
Update: forgot about that syntax...
You need to use following syntax:
UPDATE test,tbl SET val = val + ? where name = ? and id = ?;
and bind with set as first parameter:
bs = bind(ps, [set(['name']), 'name', 1])
Original answer:
You don't need to put quotes around ?
character - when bind happens, it's correctly quotes the text & other types.
P.S. Please note, that if you use {?}
, this means that you always insert one element into the set. If you need more, then you need to use just ?
, and pass a python set as an argument.