I have a bunch of python methods that follow this pattern:
def delete_session(guid): conn = get_conn() cur = conn.cursor() cur.execute(\"delete
A decorator?
class SqlExec: def __init__ (self, f): self.f = f def __call__ (self, *args): conn = get_conn() cur = conn.cursor() cur.execute(self.f (*args)) conn.commit() conn.close() @SqlExec def delete_session(guid): return "delete from sessions where guid=%s" % guid