langchain/memory/chat_message_histories/cassandra.py/CassandraChatMessageHistory/_prepare_cassandra
class CassandraChatMessageHistory:    def _prepare_cassandra(self) -> None:
        """Create the keyspace and table if they don't exist yet"""

        from cassandra import OperationTimedOut, Unavailable

        try:
            self.session.execute(
                f"""CREATE KEYSPACE IF NOT EXISTS 
                {self.keyspace_name} WITH REPLICATION = 
                {{ 'class' : 'SimpleStrategy', 'replication_factor' : 1 }};"""
            )
        except (OperationTimedOut, Unavailable) as error:
            logger.error(
                f"Unable to create cassandra \
                chat message history keyspace: {self.keyspace_name}."
            )
            raise error

        self.session.set_keyspace(self.keyspace_name)

        try:
            self.session.execute(
                f"""CREATE TABLE IF NOT EXISTS 
                {self.table_name} (id UUID, session_id varchar, 
                history text,  PRIMARY KEY ((session_id), id) );"""
            )
        except (OperationTimedOut, Unavailable) as error:
            logger.error(
                f"Unable to create cassandra \
                chat message history table: {self.table_name}"
            )
            raise error