jyotsna
jyotsna

Reputation: 11

How can we set consistency level seperatly for read and write in cassandra (cqlsh)

Can someone help me on how to set consistency level separately for read and write in cassandra (cqlsh) and one more question can we set consistency level for a keyspace? please explain

Upvotes: 0

Views: 1565

Answers (3)

LetsNoSQL
LetsNoSQL

Reputation: 1538

You can set consistency after login CQLSH like below for read and write. CONSISTENCY ONE/TWO; etc https://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlshConsistency.html

Also,you can refer below for setting a Consistency Level with Prepared Statements https://datastax.github.io/python-driver/getting_started.html

Upvotes: 0

Alex Ott
Alex Ott

Reputation: 87069

For setting this in cqlsh you need to issue corresponding CONSISTENCY command before executing the specific query, like this:

CONSISTENCY QUORUM;
INSERT INTO ... ;

Setting the consistency level for "class" of queries is impossible in cqlsh...

Upvotes: 1

Raj Parekh
Raj Parekh

Reputation: 192

Yes, you can set consistency level other then your default consistency level. (which you have defined while building your cluster object).

Here is the example of setting consistency level to your prepared statement.

session.prepare(<Query>).setConsistencyLevel(<consistency_level>)

If you are using JAVA driver, you can explore the enum class ConsistencyLevel defined in the datastax driver library.

import com.datastax.driver.core.ConsistencyLevel.{consistency_level}

This link might help you dmlConfigConsistency

Upvotes: 1

Related Questions