Objective:
Create a class named DBExtractor in the module mingle/utilities/db_utils.py that stores a reference to a provided table object and exposes its column mapping.
Requirements:
Implement class: DBExtractor
Location: mingle/utilities/db_utils.py
Initialization:
Accept a single argument (positional or keyword): table
Validate that the table object has an attribute named c (the column mapping)
If the table lacks a c attribute, raise a clear TypeError (e.g., "table must have a 'c' attribute representing column mappings")
Store the input table on self.table
Expose the column map on self.cols equal to table.c
Typing:
Use type hints where appropriate (e.g., self.table: Any, self.cols: Mapping[str, Any])
Behavior:
Do not modify the input table
Should be usable by the provided pytest test, which checks:
isinstance(x, DBExtractor)
x.table is the same object as test_table
x.cols is test_table.c
Optional:
Include a brief docstring describing the purpose and expected shape of the table (c should be a mapping of column labels to values/indices)
No external dependencies beyond standard typing
Acceptance criteria:
The tests provided (which instantiate DBExtractor with a table-like object having attributes c and metadata) pass:
x is an instance of DBExtractor
x.table equals the input table object
x.cols equals input_table.c
Example usage (conceptual):
from mingle.utilities.db_utils import DBExtractor
tbl = some_table_with_attr_c_and_metadata
extractor = DBExtractor(table=tbl)
assert extractor.table is tbl
assert extractor.cols is tbl.c
BONUS: Complete this task as quickly as possible. Faster solutions are preferred.