'Saves labels from a dictionary in a single database operation.'

def savemessageslabelsbulk(self, labels):

    for (uid, lb) in labels.items():
        self.messagelist[uid]['labels'] = lb
    self.save()
