Execute several statements in single DB transaction.

def execute_transaction(conn, statements: Iterable):
    """Execute several statements in single DB transaction."""

    with conn:
        with conn.cursor() as cursor:
            for statement in statements:
                cursor.execute(statement)
        conn.commit()