etl_lib.data_sink.SQLBatchSink module
- class SQLBatchSink(context, task, predecessor, query)[source]
Bases:
BatchProcessorBatchProcessor to write batches of data to an SQL database.
- Parameters:
context (ETLContext)
task (Task)
predecessor (BatchProcessor)
query (str)
- __init__(context, task, predecessor, query)[source]
Constructs a new SQLBatchSink.
- Parameters:
context (
ETLContext) – ETLContext instance.task (
Task) – Task instance owning this batchProcessor.predecessor (
BatchProcessor) – BatchProcessor which get_batch function will be called to receive batches to process.query (
str) – SQL query to write data. Data will be passed as a batch using parameterized statements (:param_name syntax).
- get_batch(batch_size)[source]
Provides a batch of data to the caller.
The batch itself could be called and processed from the provided predecessor or generated from other sources.
- Parameters:
max_batch__size – The max size of the batch the caller expects to receive.
batch_size (int)
- Return type:
- Returns
A generator that yields batches.