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

def savemessageslabelsbulk(self, labels):

    data = [(',    '.join(sorted(l)), uid) for (uid, l) in labels.items()]
    self.__sql_write('UPDATE    status    SET    labels=?    WHERE    id=?', data, executemany=True)
    for (uid, l) in labels.items():
        self.messagelist[uid]['labels'] = l
