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:
objectSynchronous 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)
For conditional batches (
IF NOT EXISTS/IF ...) the outcome is returned byexecute()and also kept onbatch.result.- add(stmt: str, params: list[Any]) None
Add a CQL statement to the batch.
- class coodie.batch.AsyncBatchQuery(logged: bool = True, batch_type: str | None = None, timestamp: int | None = None)
Bases:
objectAsynchronous 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)
For conditional batches (
IF NOT EXISTS/IF ...) the outcome is returned byexecute()and also kept onbatch.result.- add(stmt: str, params: list[Any]) None
Add a CQL statement to the batch.