'Merge a list of sync points with the incoming sync table.
:param sync_points: list of sync points where a sync point is a dict of
{\'sync_point\', \'remote_id\'}
:param incoming: if True, get the last incoming sync, otherwise get
the last outgoing sync'

def merge_syncs(self, sync_points, incoming=True):

    with self.get() as conn:
        for rec in sync_points:
            try:
                conn.execute(('\n                                                                                                INSERT    INTO    %s_sync    (sync_point,    remote_id)\n                                                                                                VALUES    (?,    ?)\n                                                                                ' % ('incoming' if incoming else 'outgoing')), (rec['sync_point'], rec['remote_id']))
            except sqlite3.IntegrityError:
                conn.execute(('\n                                                                                                UPDATE    %s_sync    SET    sync_point=max(?,    sync_point)\n                                                                                                WHERE    remote_id=?\n                                                                                ' % ('incoming' if incoming else 'outgoing')), (rec['sync_point'], rec['remote_id']))
        conn.commit()
