(
self,
context: DefaultExecutionContext,
cursor_strategy: ResultFetchStrategy,
cursor_description: Optional[_DBAPICursorDescription],
)
| 1531 | connection: Connection |
| 1532 | |
| 1533 | def __init__( |
| 1534 | self, |
| 1535 | context: DefaultExecutionContext, |
| 1536 | cursor_strategy: ResultFetchStrategy, |
| 1537 | cursor_description: Optional[_DBAPICursorDescription], |
| 1538 | ): |
| 1539 | self.context = context |
| 1540 | self.dialect = context.dialect |
| 1541 | self.cursor = context.cursor |
| 1542 | self.cursor_strategy = cursor_strategy |
| 1543 | self.connection = context.root_connection |
| 1544 | self._echo = echo = ( |
| 1545 | self.connection._echo and context.engine._should_log_debug() |
| 1546 | ) |
| 1547 | |
| 1548 | if cursor_description is not None: |
| 1549 | # inline of Result._row_getter(), set up an initial row |
| 1550 | # getter assuming no transformations will be called as this |
| 1551 | # is the most common case |
| 1552 | |
| 1553 | metadata = self._init_metadata(context, cursor_description) |
| 1554 | |
| 1555 | _make_row: Any |
| 1556 | _make_row = functools.partial( |
| 1557 | Row, |
| 1558 | metadata, |
| 1559 | metadata._effective_processors, |
| 1560 | metadata._key_to_index, |
| 1561 | ) |
| 1562 | |
| 1563 | if context._num_sentinel_cols: |
| 1564 | sentinel_filter = operator.itemgetter( |
| 1565 | slice(-context._num_sentinel_cols) |
| 1566 | ) |
| 1567 | |
| 1568 | def _sliced_row(raw_data: Any) -> Any: |
| 1569 | return _make_row(sentinel_filter(raw_data)) |
| 1570 | |
| 1571 | sliced_row = _sliced_row |
| 1572 | else: |
| 1573 | sliced_row = _make_row |
| 1574 | |
| 1575 | if echo: |
| 1576 | log = self.context.connection._log_debug |
| 1577 | |
| 1578 | def _log_row(row: Any) -> Any: |
| 1579 | log("Row %r", sql_util._repr_row(row)) |
| 1580 | return row |
| 1581 | |
| 1582 | self._row_logging_fn = _log_row |
| 1583 | |
| 1584 | def _make_row_2(row: Any) -> Any: |
| 1585 | return _log_row(sliced_row(row)) |
| 1586 | |
| 1587 | make_row = _make_row_2 |
| 1588 | else: |
| 1589 | make_row = sliced_row # type: ignore[assignment] |
| 1590 | self._set_memoized_attribute("_row_getter", make_row) |
nothing calls this directly
no test coverage detected