Skip to content

fetchall doesn't respect the cursor position #414

@boiledfroginthewell

Description

@boiledfroginthewell

Expected behavior

After some rows are fetched, fetchall() should return remaining rows as PEP-0249 says:

https://peps.python.org/pep-0249/#fetchall
Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples). Note that the cursor’s arraysize attribute can affect the performance of this operation.

Actual behavior

fetchall() returns all the rows.

Steps To Reproduce

cur = conn.cursor()
cur.execute("SELECT * FROM ( VALUES (1), (2), (3), (4), (5), (6))")
print(cur.fetchmany(2))
print(cur.fetchall()) # should return 4 rows
print(cur.fetchmany(10)) # should return no rows

Actual Outputs:

[[1], [2]]
[[1], [2], [3], [4], [5], [6]]
[[3], [4], [5], [6]]

Expected Outputs:

[[1], [2]]
[[3], [4], [5], [6]]
[]

Log output

No response

Operating System

Manjaro Linux

Trino Python client version

0.327.0

Trino Server version

427

Python version

3.11.5

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions