Skip to content

Instantly share code, notes, and snippets.

def autocommit(fn):
def wrapper(*args, **kwargs):
self = args[0]
cmd = fn(*args, **kwargs)
if isinstance(self, Transaction):
self.commands.append(cmd)
return cmd
else:
return cmd.execute()
return wrapper