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
-
If I run a
Is it possible to get the number of rows affected back from a sqlx query in some way? |
Beta Was this translation helpful? Give feedback.
Answered by
mplanchard
Feb 8, 2023
Replies: 1 comment
-
Ah, I found it. For postgres, at least, there's a let rows_affected = query!("DELETE FROM mytable").execute(cxn).await.unwrap().rows_affected() |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mplanchard
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, I found it. For postgres, at least, there's a
.rows_affected()
method on thePgQueryResult
that comes back from an operation, which is the Ok variant of the Result returned by e.g. the.execute()
future, so like: