Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use a decorator to automatically commit after public methods #64

Open
dlqqq opened this issue Apr 9, 2023 · 0 comments
Open

use a decorator to automatically commit after public methods #64

dlqqq opened this issue Apr 9, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@dlqqq
Copy link
Collaborator

dlqqq commented Apr 9, 2023

Problem

Forgetting to call self.con.commit() imperatively can be the source of a lot of silly bugs, as seen in #63.

Setting autocommit=True is bad for performance, as a single batched commit is significantly faster than multiple commits. The way this is currently being managed is that private methods never commit, and public methods should always commit right before returning the value. However, this currently needs to be done imperatively at every possible return point in each public method, which is fragile.

Proposed Solution

There should be a @commit decorator that wraps every public method.

@dlqqq dlqqq added the enhancement New feature or request label Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant