<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def in_transaction(self):
 """Check if this database is in a transactional context."""

        if not hasattr(self.local, 'tx'):
            return False
        return len(self.local.tx) > 0