Skip to content

[Question] Cursor docs #475

Closed
Closed
@lynxknight

Description

@lynxknight

async with con.transaction():

Or, alternatively, you can iterate over the cursor manually (cursor won't be prefetching any rows):

async def iterate(con: Connection):
    async with con.transaction():
        # Postgres requires non-scrollable cursors to be created
        # and used in a transaction.

        async with con.transaction():
            # Create a Cursor object
            cur = await con.cursor('SELECT generate_series(0, 100)')

I don't undestand why nested transaction is necessary here. Can someone elaborate?

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