<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_instance(model, _commit=True, **kwargs):
 """Add instance to database. :param model: a string, model name in rio.models :param _commit: control whether commit data to database or not. Default True. :param \*\*kwargs: persisted data. :return: instance id. """

    try:
        model = get_model(model)
    except ImportError:
        return None

    instance = model(**kwargs)
    db.session.add(instance)

    try:
        if _commit:
            db.session.commit()
        else:
            db.session.flush()
        return instance.id
    except IntegrityError:
        db.session.rollback()
        return