MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / manyrows

Method manyrows

lib/sqlalchemy/engine/_result_cy.py:444–486  ·  view source on GitHub ↗
(self: Self, num: int | None, /)

Source from the content-addressed store, hash-verified

442 uniques, strategy = self._unique_strategy
443
444 def manyrows(self: Self, num: int | None, /) -> Sequence[_R]:
445 made_rows: Sequence[Any]
446 collect: list[_R] = []
447
448 _manyrows = self._fetchmany_impl
449
450 if num is None:
451 # if None is passed, we don't know the default
452 # manyrows number, DBAPI has this as cursor.arraysize
453 # different DBAPIs / fetch strategies may be different.
454 # do a fetch to find what the number is. if there are
455 # only fewer rows left, then it doesn't matter.
456 if yield_per:
457 num_required = num = yield_per
458 else:
459 rows = _manyrows()
460 num = len(rows)
461 made_rows = (
462 rows if make_rows is None else make_rows(rows)
463 )
464 _apply_unique_strategy(
465 made_rows, collect, uniques, strategy
466 )
467 num_required = num - len(collect)
468 else:
469 num_required = num
470
471 assert num is not None
472
473 while num_required:
474 rows = _manyrows(num_required)
475 if not rows:
476 break
477
478 made_rows = rows if make_rows is None else make_rows(rows)
479 _apply_unique_strategy(
480 made_rows, collect, uniques, strategy
481 )
482 num_required = num - len(collect)
483
484 if post_creational_filter is not None:
485 collect = [post_creational_filter(row) for row in collect]
486 return collect
487
488 else:
489

Callers

nothing calls this directly

Calls 2

_fetchmany_implMethod · 0.95
_apply_unique_strategyFunction · 0.85

Tested by

no test coverage detected