def create_db_links(txt_tuple_iter, detail_page):
    """
    From an iterable containing DB info for records in DB or 'not in DB' when no
    instances were found, returns info formatted as url links to detail pages of
    the records.

    :param txt_tuple_iter: an iterable of tuples where the 0 element of the
                          tuple is the text to display in the link and element
                          1 is the key value to build the link (iter of tuples)
    :detail_page: the details page relevant to the entries being processed (str)
    :return: string containing links to each entry (str)
    """
    if txt_tuple_iter != 'not in DB':
        line_links = []
        for txt, key in txt_tuple_iter:
            line_links.append('<a target="_blank" href="/%s/%s">%s</a>'
                               % (detail_page, key, txt))
        line = ', '.join(line_links)
    else:
        line = 'not in DB'
    return line