<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_all_database_reactions(model, compartments):
 """Add all reactions from database that occur in given compartments. Args: model: :class:`psamm.metabolicmodel.MetabolicModel`. """


    added = set()
    for rxnid in model.database.reactions:
        reaction = model.database.get_reaction(rxnid)
        if all(compound.compartment in compartments
               for compound, _ in reaction.compounds):
            if not model.has_reaction(rxnid):
                added.add(rxnid)
            model.add_reaction(rxnid)

    return added