conn.execute return value

Open
#1,238 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
postgresql, python
Domain
databases

Research direction

Start at the conn.execute entry point and reproduce the two single-statement and multi-statement examples against the reported asyncpg 0.30 and Python 3.11 setup. Done would require an agreed behavior or documentation change for execute's return value; the issue does not name a file or test.

Written by the indexing model from the issue text.

Description

asyncpg version: 0.30
PostgreSQL version:
Do you use a PostgreSQL SaaS? If so, which? Can you reproduce the issue with a local PostgreSQL install?:
Python version: 3.11
Platform: Ubuntu
Do you use pgbouncer?: No
Did you install asyncpg with pip?: Yes
If you built asyncpg locally, which version of Cython did you use?:
Can the issue be reproduced under both asyncio and uvloop?: NA

When I do execute on a connection, the return value looks like it brings back the number of rows with SELECT prepended to it.

Example:
If you run:

conn.execute("SELECT now();")

The output is SELECT 1

If you run:

conn.execute("SELECT generate_series(0, 100);")

The output is SELECT 101

Obviously with a fetch it brings back the correct result, but I am specifically interested in the return value of a multi statement execute.

ie, I want to do

conn.execute("SELECT generate_series(0, 100); SELECT now();")

And the return value should be the last return value.

Is this possible? What am I missing?

Thanks in advance

And PS. The ISSUE_TEMPLATE is not applying when creating the issue, I copied it in.

Dominant language
Python
Stars
8.1k
Forks
469
Avg merge
2d 20h
Merged PRs (30d)
9

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MagicStack/asyncpg

All issues in MagicStack/asyncpg

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.