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 aList[str]is passed it will create multiple statements, one for each name. If set toNone, theCassandraKeyspace.nameis used instead.
- replication_strategy str(Default:SimpleStrategy): Keyspace replication strategy.
- replication_factor int or Dict[str, int](Default:3): Keyspace replication factor. When using theSimpleStrategyreplication strategy, this parameter should be an integer. When using theNetworkTopologyStrategyreplication 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): IfTrueaddsIF NOT EXISTSoption to the statement(s). Attempting to create a keyspace that already exists will return an error unless theIF NOT EXISTSoption 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 aList[str]is passed it will create multiple statements, one for each name. If set toNone, theCassandraKeyspace.nameis used instead.
- if_exists bool(Default:False): IfTrueaddsIF EXISTSoption to the statement(s). If the keyspace does not exists, the statement will return an error, unlessIF EXISTSis 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 aList[str]is passed it will create multiple statements, one for each name. If set toNone, theCassandraKeyspace.nameis used instead.
- replication_strategy str(Default:SimpleStrategy): Keyspace replication strategy.
- replication_factor int or Dict[str, int](Default:3): Keyspace replication factor. When using theSimpleStrategyreplication strategy, this parameter should be an integer. When using theNetworkTopologyStrategyreplication strategy, this should be a dictionary mapping data center names to an integer representing the replication factor in that data center.
Return: self