1

I am a newbie to the world of cassandra. I am trying to find the right api in cassandra cqlengine, which I can use to update a record only if one exists previously.

The examples that I have come across do not tackle this particular case and my brute force attempts to get to the answer have failed :(.

From: https://datastax.github.io/python-driver/cqlengine/batches.html

# updating in a batch
b = BatchQuery()
em1.description = "new description"
em1.batch(b).save()
em2.description = "another new description"
em2.batch(b).save()
b.execute()

I have already tried doing if_exists on the model and batch object. It ends up creating new object.

Thanks in advance.

user1855193
  • 123
  • 3
  • 10
  • you are looking for light weight transactions http://docs.datastax.com/en/cql/3.1/cql/cql_using/use_ltweight_transaction_t.html corresponding python driver use-case https://datastax.github.io/python-driver/lwt.html... – undefined_variable Mar 03 '17 at 11:12
  • https://datastax.github.io/python-driver/api/cassandra/cqlengine/query.html if_exists() function is available – undefined_variable Mar 03 '17 at 11:17
  • It does, but the following produces a standard `INSERT INTO ...` query. The OP is asking for the `UPDATE ... ` query equivalent. – krizajb Oct 17 '18 at 09:48

0 Answers0