Justin Thomas
Justin Thomas

Reputation: 5848

Python Cassandra Driver Only Inserts One Record

Trying to get this insert to work and only a single record gets inserted despite not seeing any errors. It works normally if I spell out the fields, but doing it with the JSON literal is much easier.

Doing this in a loop from stdin:

batch = BatchStatement(consistency_level=ConsistencyLevel.QUORUM)
stmt = cassy_session.prepare("INSERT INTO social_objects JSON ?;")
batch.add(stmt, (json.dumps(so_record),))
stmt = cassy_session.prepare("INSERT INTO social_users JSON ?;")
batch.add(stmt, (json.dumps(user_record),))
cassy_session.execute(batch)

Also tried this:

cassy_session.execute(stmt, [json.dumps(user_record)])

Upvotes: 1

Views: 199

Answers (1)

Tyler Hobbs
Tyler Hobbs

Reputation: 6932

I believe you're seeing CASSANDRA-10631, which affects prepared INSERT JSON statements. This should be fixed in Cassandra 2.2.4.

Upvotes: 3

Related Questions