Batch Operations

Context managers for grouping multiple CQL statements into a single atomic batch.

class coodie.batch.BatchQuery(logged: bool = True, batch_type: str | None = None, timestamp: int | None = None)

Bases: object

Synchronous batch context manager.

Accumulates CQL statements and executes them as a single batch on exit.

Example:

from coodie.sync import BatchQuery

with BatchQuery() as batch:
    Product(name="A").save(batch=batch)
    Product(name="B").save(batch=batch)
add(stmt: str, params: list[Any]) None

Add a CQL statement to the batch.

execute() None

Execute the accumulated batch immediately.

class coodie.batch.AsyncBatchQuery(logged: bool = True, batch_type: str | None = None, timestamp: int | None = None)

Bases: object

Asynchronous batch context manager.

Accumulates CQL statements and executes them as a single batch on exit.

Example:

from coodie.aio import AsyncBatchQuery

async with AsyncBatchQuery() as batch:
    await Product(name="A").save(batch=batch)
    await Product(name="B").save(batch=batch)
add(stmt: str, params: list[Any]) None

Add a CQL statement to the batch.

async execute() None

Execute the accumulated batch immediately.