Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

"It will also return the number of affected rows." - update method #42

Open
GabrielBellard opened this issue Jul 15, 2019 · 1 comment

Comments

@GabrielBellard
Copy link

GabrielBellard commented Jul 15, 2019

In the github doc it is written that the update "[...] will also return the number of affected rows." but looking at the code, it does not seem the case.

Is there a simple way to retrieve it without using the psycopg2 cursor.execute() myself ?

@nackjicholson
Copy link
Collaborator

nackjicholson commented Jul 18, 2019

You're right, I think that is a documentation mistake. Sorry about that.

I don't think there is a simple way to do what you want without getting the cursor. I did introduce a way to get the underlying database cursor for a query though.

I can't guarantee something like this will work, but I think it might. You just suffix _cursor after your query name. Best of luck, thanks for using the project. Sorry about the issue.

-- name: subscribe_user
update user set is_subscribed = true where name = :name
with queries.subscribe_user_cursor("will") as cur:
    print(cur.rowcount)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants