Skip to content

Is it possible to get the number of rows affected by a DELETE query? #2337

Answered by mplanchard
mplanchard asked this question in Q&A
Discussion options

You must be logged in to vote

Ah, I found it. For postgres, at least, there's a .rows_affected() method on the PgQueryResult that comes back from an operation, which is the Ok variant of the Result returned by e.g. the .execute() future, so like:

let rows_affected = query!("DELETE FROM mytable").execute(cxn).await.unwrap().rows_affected()

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mplanchard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant