def insert_term(c, term):
    """Inserts the term into the database and returns the ID. """
    c.execute(
        'INSERT OR IGNORE INTO search_term (term) VALUES (?);',
        (term,)
        )
    c.execute('SELECT id FROM search_term WHERE term=?;', (term,))
    search_id = c.fetchone()[0]
    return search_id