Skip to content

CassandraKeyspace

Inherits: primeight.base.CassandraBase

The CassandraKeyspace manages keyspace interactions.

Import

from primeight import CassandraKeyspace

Constructor

  • config dict [Required]: Table configuration, as returned by one of the parsers
  • cassandra_manager primeight.manager.CassandraManager (Default: None): Cassandra manager

Attributes

cassandra_manager

Type: primeight.manager.CassandraManager

Cassandra manager where to run the statements.

config

Type: dict

Table configuration, as returned by one of the parsers from the module primeight.parser.

statements

Type: List[str]

Current statements in object.

name

Type: str

Keyspace name.

Methods

create

Build keyspace CREATE statement(s).

Note

The statement is only executed using the execute methods (e.g CassandraKeyspace.execute).

Parameters:

  • name str or List[str] (Default: None): Keyspace name. If a List[str] is passed it will create multiple statements, one for each name. If set to None, the CassandraKeyspace.name is used instead.
  • replication_strategy str (Default: SimpleStrategy): Keyspace replication strategy.
  • replication_factor int or Dict[str, int] (Default: 3): Keyspace replication factor. When using the SimpleStrategy replication strategy, this parameter should be an integer. When using the NetworkTopologyStrategy replication strategy, this should be a dictionary mapping data center names to an integer representing the replication factor in that data center.
  • if_not_exists bool (Default: False): If True adds IF NOT EXISTS option to the statement(s). Attempting to create a keyspace that already exists will return an error unless the IF NOT EXISTS option is used. If it is used, the statement will be a no-op if the keyspace already exists.

Return: self

drop

Build keyspace DROP statement(s).

Note

The statement is only executed using the execute methods (e.g CassandraKeyspace.execute).

Parameters:

  • name str or List[str] (Default: None): Keyspace name. If a List[str] is passed it will create multiple statements, one for each name. If set to None, the CassandraKeyspace.name is used instead.
  • if_exists bool (Default: False): If True adds IF EXISTS option to the statement(s). If the keyspace does not exists, the statement will return an error, unless IF EXISTS is used in which case the operation is a no-op.

Return: self

alter

Build keyspace ALTER statement(s).

Note

The statement is only executed using the execute methods (e.g CassandraKeyspace.execute).

Parameters:

  • name str or List[str] (Default: None): Keyspace name. If a List[str] is passed it will create multiple statements, one for each name. If set to None, the CassandraKeyspace.name is used instead.
  • replication_strategy str (Default: SimpleStrategy): Keyspace replication strategy.
  • replication_factor int or Dict[str, int] (Default: 3): Keyspace replication factor. When using the SimpleStrategy replication strategy, this parameter should be an integer. When using the NetworkTopologyStrategy replication strategy, this should be a dictionary mapping data center names to an integer representing the replication factor in that data center.

Return: self