<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def load_case(adapter, case_obj, update=False):
 """Load a case to the database Args: adapter: Connection to database case_obj: dict update(bool):
 If existing case should be updated Returns: case_obj(models.Case) """

    # Check if the case already exists in database.
    existing_case = adapter.case(case_obj)
    if existing_case:
        if not update:
            raise CaseError("Case {0} already exists in database".format(case_obj['case_id']))
        case_obj = update_case(case_obj, existing_case)

    # Add the case to database
    try:
        adapter.add_case(case_obj, update=update)
    except CaseError as err:
        raise err

    return case_obj