Reputation: 33
I am trying to insert to this Cassandra table in Python
CREATE TABLE IF NOT EXISTS hourly (
cid TEXT,
uid BIGINT,
day DATE,
classes MAP<INT, BOOLEAN>,
PRIMARY KEY (cid, uid, day) )
With this prepared statement:
ins_hourly = cass.prepare(
"INSERT INTO hourly (cid, uid, day, classes)"
" VALUES (?, ?, ?, ?)" )
With this snippet of code (database has been opened and inserted to other tables, so connection is valid):
cid = 'foo'
uid = 11380
dt = '2019-10-14'
hr = 11
classes = {hr: True}
row = Cassandra.execute(ins_hourly, cid, uid, dt, classes)
I catch the exception: "Too many arguments provided to bind() (got 12, expected 4)".
How did the binding function manage to turn my 4 arguments into 12?
And, hopefully, any ideas on how to fix this?
Alternatively some working examples of working with Cassandra MAP, LIST, and SET from the Python driver would be appreciated.
Upvotes: 0
Views: 926
Reputation: 6218
row = Cassandra.execute(ins_hourly, (cid, uid, dt, classes))
Missing bracket in execute.
Python Cassandra prepared statement Test
Alternatively you can also use bind to bind varaibles and execute bound query.
Upvotes: 2