def search_songs_db(term, db):
    """
    Performs a search of the songs database. Searches all fields' values, as
    well as all lyrics' values.

    The search performed is strictly a sub-string search; capitalization must
    match in order for the search to be done right.

    :param term: Search term.
    :type term: `str`

    :param db: The database object to search. In this project, we use TinyDB
               for simplicity and portability (it's very, very small).
    :type db: `tinydb.TinyDB()`

    :returns: one of `filtered_songs` or `all_songs`, the search results.
    :rtype: `iterable(dict)`
    """
    filtered_songs = list()
    all_songs = db.all()
    if term:
        for song in all_songs:
            for k, v in song.items():
                if k == "lyrics":
                    for sec, txt in v.items():
                        if txt and term in txt and song not in filtered_songs:
                            filtered_songs.append(song)
                else:
                    if v and term in v and song not in filtered_songs:
                        filtered_songs.append(song)
        return filtered_songs
    else:
        return all_songs