question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support returning the rowcount for a given query?

See original GitHub issue

Hey! Thanks for this awesome library.

I’m replacing direct aiopg usage with it, but I ran into one issue that I can’t seem to solve. When executing a query aiopg returns an object with a .rowcount attribute. This is quite handy when using an INSERT ... ON CONFLICT query to know how many rows have been inserted.

I cannot seem to find out to how expose this information with this library. I’m guessing it might be more of an issue with asyncpg, but I was wondering if this is possible and if could be documented somewhere?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
tomchristiecommented, Jun 19, 2019

Currently we’re underspecifying the return type from execute, and returning the lastrowid value.

It looks like we probably ought to be returning a richer interface from that, with at least .lastrowid, and .rowcount attributes being supported. Does that sound like the right interface to you folks?

3reactions
gnatcommented, Aug 7, 2019

@tomchristie execute does not return feedback when deleting rows. Returning rows affected would be the standard MySQL way.

https://github.com/encode/databases/blob/88b381ae33bcb417b76b8df9149742cbbcc253b5/databases/backends/mysql.py#L134

Always returns 0 because the row no longer exists.

Is there any way to get feedback from a delete?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with SQL Server ROWCOUNT - SQLShack
To overcome this issue, SQL Server introduces the ROWCOUNT_BIG system function, which returns the number of rows affected by a specific query in ......
Read more >
@@ROWCOUNT (Transact-SQL) - SQL Server | Microsoft Learn
Statements that make an assignment in a query or use RETURN in a query set the @@ROWCOUNT value to the number of rows...
Read more >
return @@rowcount result on SQL query - Stack Overflow
I wanted to raiserror if exists and then print the number of rows that are matching .But this doesnt work . Please help...
Read more >
Optimize query that only returns when the number of rows to ...
1. Presumably you can estimate the odds a call will hit the row count threshold vs not? · @LowlyDBA Yes, we could estimate,...
Read more >
Limiting the number of returned rows - Ask TOM
next update/delete/insert *appears* to work but doesn't (only does 20 rows). been there, done that. rowcount on the query is the way to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found