def dbKeys(db):
    """
    Fetch name, CAS, and formula from db and return them as a list of tuples

    Parameters:
        db, nested dictionary like {'<name>':{'CAS':'', 'formula':'', ...}}
    
    Returns:
        nCF, list of tuples like [('name0','CAS0','formula0'),
                                  ('name1','CAS1','formula1'),
                                  ...]
    Notes:
        extract names, CAS, and formulas to separate tuples via zip, e.g.:
            dbNames, dbCAS, dbFormula = zip(*dbKeys(db))
        
    """
    nCF = []
    for k in db.keys():
        if 'CAS' in db[k].keys():
            CAS = db[k]['CAS']
        else:
            CAS = ""
        if 'formula' in db[k].keys():
            formula = db[k]['formula']
        else:
            formula = ""
        nCF.append((k,CAS,formula))
        
    return nCF