@staticmethod
def ensure_snippet(snippet, piece_id, part_id, conn, cursor):
    """
        Ensure the given snippet is included
            :param snippet: Snippet instance to store
            :param piece_id: Id of source piece
            :param part_id: Id of source part
            :param conn: Connection to sqlite instance
            :param cursor: Cursor to use
        """
    cursor.execute(
        'SELECT id FROM snippets WHERE piece_id=? AND part_id=? AND offset=?',
        (piece_id, part_id, snippet.offset))
    results = cursor.fetchall()
    if results:
        return results[0][0]
    cursor.execute(
        'INSERT INTO snippets (piece_id, part_id, offset) VALUES (?, ?, ?)',
        (piece_id, part_id, snippet.offset))
    conn.commit()
    return cursor.lastrowid
