MagicStack / asyncpg

A fast PostgreSQL Database Client Library for Python/asyncio.
Apache License 2.0
6.99k stars 404 forks source link

Allow executemany to return rows #1110

Closed LeonardBesson closed 3 weeks ago

LeonardBesson commented 10 months ago

Fixes https://github.com/MagicStack/asyncpg/issues/448

This is a proposed change to support executemany with INSERT ... RETURNING.

The PR adds a flag parameter to executemany, but adding a seperate method like fetchmany was also mentioned.

@elprans would you consider something along those lines? I think the value here is allowing to take advantage of the query pipelining from executemany while avoiding the limitations of the proposed workarounds (like DEFAULT as mentioned in your stackoverflow post)

elprans commented 3 months ago

Plausible. I'm not a fan of changing the function signature based on the argument though. I think this should be a separate method, e.g. fetchmany or something like that (though could be somewhat confusing for DB-API users).

elprans commented 3 weeks ago

Ability to return values added as fetchmany in #1175.