Skip to content

Managing Materialized Views

Warning

Materialized Views are experimental and are not recommended for production use.

primeight allows the management of Cassandra materialized views, namely, the creation and drop of materialized views.

primeight tries to make these tasks the easiest experience possible.

Creating materialized views

from primeight import CassandraManager, CassandraMaterializedView
from primeight.parser import YamlParser

config = YamlParser.parse("devices.yaml")

manager = CassandraManager(["127.0.0.1"])
manager.connect()

view = CassandraMaterializedView(config, 'devices_by_time', cassandra_manager=manager)
view.create().execute()

or using a dynamic keyspace name:

from primeight import CassandraManager, CassandraMaterializedView
from primeight.parser import YamlParser

config = YamlParser.parse("devices.yaml")

manager = CassandraManager(["127.0.0.1"])
manager.connect()

view = CassandraMaterializedView(config, 'devices_by_time', cassandra_manager=manager)

client_name = "Client ABC"
view.create(keyspace=client_name.replace(' ', '-')).execute()

You can read more on the parameters of the create method here.

Dropping materialized views

primeight tries to make the creation of materialized views the easiest experience possible.

from primeight import CassandraManager, CassandraMaterializedView
from primeight.parser import YamlParser

config = YamlParser.parse("devices.yaml")

manager = CassandraManager(["127.0.0.1"])
manager.connect()

view = CassandraMaterializedView(config, 'devices_by_time', cassandra_manager=manager)
view.drop().execute()

You can read more on the parameters of the drop method here.