Skip to main content
  • Iterates the results of an SQL statement, fetching in batches.

    Pages through the result set so arbitrarily large queries can be consumed without holding everything in memory at once, cleaning up any server-side paging tables when iteration finishes — including when the caller breaks out of the loop early.

    Records are yielded as objects keyed by column name. This differs from the JavaScript API, which yields positional arrays; use Object.values(record) if you need those.

    Parameters

    • sql: string

      The SQL statement to execute

    • batchSize: number = 10000

      Records to fetch per batch; defaults to 10000

    • sqlOptions: Record<string, string> =

      Options passed through to /execute/sql

    Returns AsyncGenerator<Record<string, any>, void, undefined>