Пример #1
0
 def song_update(self):
     s_id = input("enter song's id: ")
     if Check.check_song(s_id):
         name = input("enter song's name: ")
         language = input("enter song's language: ")
         album_id = input("enter id of album in which song is: ")
         while not Check.check_album(album_id):
             string = input(
                 "There is no such album\nYou can add it\n(y/n): ")
             for case in Switch(string):
                 if case('y'):
                     album = self.album_input()
                     album_id = album.id
                     db.insert_album(album)
                     break
                 if case('n'):
                     print("can't insert song")
                     return
                 else:
                     print("wrong input, try again!")
         song = Song(s_id, name, language, album_id)
         return song
     else:
         print("No such song in db")
         return None
Пример #2
0
 def album_update(self):
     a_id = input("enter album's id: ")
     if Check.check_album(a_id):
         name = input("enter album's name: ")
         presentation_date = self.get_date()
         songs_number = input("enter number of songs in album: ")
         band_id = input("enter id of band which created album: ")
         while not Check.check_band(band_id):
             string = input(
                 "There is no such band\nYou can add it\n(y/n): ")
             for case in Switch(string):
                 if case('y'):
                     band = self.band_input()
                     band_id = band.id
                     db.insert_band(band)
                     break
                 if case('n'):
                     print("can't insert album")
                     return
                 else:
                     print("wrong input, try again!")
         album = Album(a_id, name, presentation_date, songs_number, band_id)
         return album
     else:
         print("No such album in db")
         return None
Пример #3
0
def delete_entity(name):
    if name == "band":
        band_id = ui.get_id()
        if Check.check_band(band_id):
            db.delete_band(band_id)
        else:
            print("There is no such band in db\n")

    elif name == "album":
        album_id = ui.get_id()
        if Check.check_album(album_id):
            db.delete_album(album_id)
        else:
            print("There is no such album in db\n")

    elif name == "song":
        song_id = ui.get_id()
        if Check.check_song(song_id):
            db.delete_song(song_id)
        else:
            print("There is no such song in db\n")