'Return hosts from the database.'

def get_hosts(self, filterTerm=None):

    cur = self.conn.cursor()
    if self.is_host_valid(filterTerm):
        cur.execute('SELECT    *    FROM    hosts    WHERE    id=?    LIMIT    1', [filterTerm])
    elif (filterTerm and (filterTerm != '')):
        cur.execute('SELECT    *    FROM    hosts    WHERE    ip    LIKE    ?    OR    LOWER(hostname)    LIKE    LOWER(?)', ['%{}%'.format(filterTerm.lower()), '%{}%'.format(filterTerm.lower())])
    else:
        cur.execute('SELECT    *    FROM    hosts')
    results = cur.fetchall()
    cur.close()
    return results
