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

Within transaction, the error disappeared #195

Open
nexttonever opened this issue Jul 17, 2020 · 1 comment
Open

Within transaction, the error disappeared #195

nexttonever opened this issue Jul 17, 2020 · 1 comment

Comments

@nexttonever
Copy link

code like this:
db = ...
with db.transaction() as tx:
tx.query(...) # raise an sql error

but the error raised by tx.query disappears.
I found the code:
def transaction(self):
"""A context manager for executing a transaction on this Database."""

    conn = self.get_connection()
    tx = conn.transaction()
    try:
        yield conn
        tx.commit()
    except:
        tx.rollback()
        raise   # This may be the solution
    finally:
        conn.close()
@kennethreitz
Copy link
Owner

Ask yourself this —

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

No branches or pull requests

2 participants