Skip to content

executemany not discarding result aka fetchmany #137

Closed
@samuelcolvin

Description

@samuelcolvin

With the following query

INSERT INTO people (name) VALUES ($1)
RETURNING id

and values to create [('anne',), ('ben',), ('charlie',)].

I believe there's currently no way with asyncpg to execute this single query and get all the ids returned.

I've tried:

  • executemany but the result is discarded
  • fetch but that doesn't extend to executing many
  • fetch while casting the argument to an array ::TEXT[][] but I either get a syntax error or a single value of the stringified list insert.

In short: would it be possible for executemany to return the result?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions