bi_etl.bulk_loaders.bulk_loader module
- class bi_etl.bulk_loaders.bulk_loader.BulkLoader(rows_per_file: int | None = None)[source]
Bases:
ABCBase class for loaders that load rows into a database table using the database’s bulk load facility.
Subclasses must implement
load_from_iterable(). Loaders that work from files can also implementload_from_files().- DEFAULT_ROWS_PER_FILE = 25000
- __init__(rows_per_file: int | None = None)[source]
Create the logger and the empty set of values to redact from logged messages.
- add_redact_value(redact_value: str)[source]
Register a value (such as a password) that
log_with_redactions()must hide.- Parameters:
redact_value¶ – Text to replace with asterisks in logged messages. None is ignored.
- load_from_files(local_files: list, table_object: Table, table_to_load: str | None = None, perform_rename: bool = False, file_compression: str = '', options: str = '', analyze_compression: str | None = None) int[source]
Note: This method is NOT required for all bulk loaders.
- abstractmethod load_from_iterable(iterable: Iterable[Row], table_object: Table, table_to_load: str | None = None, perform_rename: bool = False, progress_frequency: int = 10, analyze_compression: str | None = None, parent_task: ETLTask | None = None) int[source]
Note: This method is IS required for all bulk loaders.
- load_table_from_cache(table_object: Table, table_to_load: str | None = None, perform_rename: bool = False, progress_frequency: int = 10, analyze_compression: str | None = None) int[source]
Bulk load the rows cached by table_object using
load_from_iterable().- Parameters:
table_object¶ – Table whose cache is loaded.
table_to_load¶ – Name of the table (or temp table) that was loaded, used for the rename.
perform_rename¶ – If True, call
rename_table()after the load.progress_frequency¶ – Seconds between progress log messages.
analyze_compression¶ – Passed through to
load_from_iterable().
- Returns:
Number of rows loaded.
- Return type:
- log_with_redactions(*, log_level: int, message: str)[source]
Log message after replacing every registered redaction value with asterisks.
- Parameters:
log_level¶ – Logging level, such as
logging.INFO.message¶ – Text to log.
- property needs_all_columns
True if the rows passed to the loader must contain every column of the target table, in table order.
- Returns:
True by default. Loaders that can map columns by name override this to return False.
- Return type: