db
Database utils module.
- class mltb2.db.AbstractBatchDataManager[source]
Bases:
ABC
Abstract base class for batch processing of database data.
This class (respectively an implementation of it) is intended to be used in conjunction with the
BatchDataProcessor
.
- class mltb2.db.BatchDataProcessor(data_manager: AbstractBatchDataManager, process_batch_callback: Callable[[Sequence], Sequence])[source]
Bases:
object
Process batches of data from a database.
- Parameters:
data_manager (AbstractBatchDataManager) – The data manager to load and save batches of data.
process_batch_callback (Callable[[Sequence], Sequence]) – A callback function that processes one batch of data.
- run() None [source]
Run the batch data processing.
This is done until the data manager returns an empty batch. For each batch the
process_batch_callback
is called. Data is loaded by using an implementation of theAbstractBatchDataManager
.- Return type:
None