def retrieveAlbums(self): sql = "SELECT * from album" cur.execute(sql) self.myAlbums = [] for row in cur: a = Album() a.album_id = row[0] a.title = row[1] a.band_name = row[2] a.band_id = row[3] self.myAlbums.append(a)
def retrieveBandAlbums(self): albums = [] sql = "SELECT * from album where band_id = '" + str(self.band_id) + "'" cur.execute(sql) for row in cur: a = Album() a.album_id = row[0] a.title = row[1] a.band_name = row[2] a.band_id = row[3] albums.append(a) return albums
MP.viewArtists() if choice2 == "5": break if choice == "3": while True: choice2 = input("1. add new Album 2. Delete Album 3. Play Songs to a certain Album" + " 4. View all Albums 5. back:\n") if choice2 == "1": album = Album() album.title = input("Enter album title:") MP.retrieveBands() MP.viewBands() bandNum = int(input("Enter band #:"))-1 album.band_name = MP.myBands[bandNum].name album.band_id = MP.myBands[bandNum].band_id album.addAlbum() if choice2 == "2": aID = int(input("Enter # of album:")) MP.retrieveAlbums() MP.myAlbums[aID-1].deleteAlbum() if choice2 == "3": MP.retrieveAlbums() MP.viewAlbums() albumNum = int(input("Enter # of album:"))-1 albumSongs = MP.myAlbums[albumNum].retrieveAlbumSongs() for i in range(0, len(albumSongs)): print(i+1, ". ", albumSongs[i].name)