Use transactions in a context manager