def get_album_dict(db_session, artist_id=None):
    album_dict = {}
    if artist_id is None:
        try:
            c = db_session.cursor()
            c.execute("""SELECT album_id, name, year, precise_rating FROM albums""")
            for row in c:
                album_id       = row[0]
                album_name     = row[1]
                album_year     = row[2]
                precise_rating = row[3]
                album_dict[album_id] = {'name'          : album_name,
                            'year'          : album_year,
                            'precise_rating' : precise_rating,
                            }
        except:
            album_dict = None
        #db_session.commit()
        c.close()
    else:
        try:
            c = db_session.cursor()
            c.execute("""SELECT album_id, name, year, precise_rating FROM albums
                WHERE artist_id = ? order by year""", [artist_id])
            for row in c:
                album_id       = row[0]
                album_name     = row[1]
                album_year     = row[2]
                precise_rating = row[3]
                album_dict[album_id] = {'name'          : album_name,
                            'year'          : album_year,
                            'precise_rating' : precise_rating,
                            }
        except:
            album_dict = None
        #db_session.commit()
        c.close()
    return album_dict
Returns a dictionary of all the albums from an artist from the database
dataset/ETHPy150Open bahamas10/Viridian/AmpacheTools/dbfunctions.py/get_album_dict