def save_artists(): users = [] artists_dict = {} i = 0 for user in users: library = get_library(user) artists = library.get_artists(None) artists_to_save = [] for artist in artists: try: artist_name = artist.item.name if artist_service.artist_exist(artist_name): continue app.logger.info(artist_name) artist_model = Artist(name=artist_name, mb_id=artist.item.get_mbid(), image_url=artist.item.get_cover_image(), bio=artist.item.get_bio_content()) artists_to_save.append(artist_model) artists_dict[i] = artist_name artist_service.insert_artist(artist_model) i += 1 except Exception: continue return artists_dict
def add_artwork_info(): artist_name = input('Enter artist name:\n') artist = Artist.get_or_none(Artist.artist_name == artist_name) if not artist: raise ArtistError(f'Error - "{artist_name}" not found') artwork_name = input('Enter artwork name:\n') price = price_check() return Artwork(artwork_name=artwork_name, price=price, artist=artist.id)
def check_whether_artist_exists(name): #checks if artist exists try: res = Artist.select().where(Artist.name == name).get() if res: return res.id else: return None except: return 'Artist does not exist'
def add_artist(name, email): try: Artist(name=name, email=email).save() print("you added new name") #except IntegrityError as e: #raise ArtError('Error adding artist because' + str(e)) except: print('not adding')
def add_artist_info(): artist_name = input('Enter artist name:\n') email = input('Enter artist email:\n') return Artist(artist_name=artist_name, email=email)
def main(): catalogContinue = 'Y' while catalogContinue.upper() == 'Y': print('Welcome to the National Artist Catalog!') print('Here are the things you can do with this catalog.') print( '1) Add a new artist\n2) Search all artwork of a particular artist' ) print( '3) Search all available artwork for an artist\n4) Add a new piece of artwork' ) print( '5) Delete a piece of artwork\n6) Change availability off a piece of artwork' ) choice = input('What would you like to do? ') if choice == 1: artistName = input('Please enter an artist name: ') artistEmail = input('Please enter the artist email: ') newArtist = Artist(name=artistName, email=artistEmail) newArtist.save() catalogContinue = input('Would you like to continue?(Y or N) ') elif choice == 2: artistSearch = input( 'Which Artist\'s work would you like to search? ') findArtwork = Artwork.select().where( Artwork.artist == artistSearch) for art in findArtwork: print(art) catalogContinue = input('Would you like to continue?(Y or N) ') elif choice == 3: artistSearch = input( 'Which Artist\'s Available artwork would you like to search? ') findAvailable = Artwork.select().where( Artwork.artist == artistSearch and Artwork.availability == 'Available') for art in findAvailable: print(art) catalogContinue = input('Would you like to continue?(Y or N) ') elif choice == 4: newArtArtist = input('Please enter this artworks artist: ') artworkName = input('Please enter the artworks name: ') newPrice = int(input('Please enter the artworks price: ')) newAvailability = input('IS this artwork Available or Sold? ') newArtwork = Artwork(artist=newArtArtist, artwork=artworkName, price=newPrice, availability=newAvailability) newArtwork.save() catalogContinue = input('Would you like to continue?(Y or N) ') elif choice == 5: artworkSearch = input('What artwork would you like to delete? ') artworkDeleted = Artwork.delete().where( Artwork.artwork == artworkSearch) print('Artwork Deleted: ', artworkDeleted) catalogContinue = input('Would you like to continue?(Y or N) ') elif choice == 6: artworkSearch = input( 'What artwork would you like to change the availability on? ') newAvailability = input('Is this artwork Available or Sold? ') availabilityChanged = Artwork.update( availability=newAvailability).where( Artwork.artwork == artworkSearch).execute() print('The following availability has been changed', availabilityChanged) catalogContinue = input('Would you like to continue?(Y or N) ') else: print('Goodbye!!')
# A DBSession() instance establishes all conversations with the database # and represents a "staging zone" for all the objects loaded into the # database session object. Any change made against the objects in the # session won't be persisted into the database until you call # session.commit(). If you're not happy about the changes, you can # revert all of them back to the last commit by calling # session.rollback() session = DBSession() # Create user user1 = User(name="Oisbel Simpson", email="*****@*****.**") session.add(user1) session.commit() # Tracks for Lauren Daigle artist0 = Artist(name="Lauren Daigle", picture="https://image.ibb.co/fiYSQm/Lauren_Daigle.png") session.add(artist0) session.commit() f = open("lyrics/Lauren Daigle-O' Lord.txt") content = f.read() f.close() track0 = Track(title="O' Lord", lyrics=content, video="https://www.youtube.com/watch?v=eHp585tdIjQ", artist=artist0, user=user1) session.add(track0) session.commit()
def generate_test_tables(): try: new_artist_1 = Artist(artist_name='Beyonce Giselle', email='*****@*****.**') new_artist_1.save() new_artist_2 = Artist(artist_name='Jay z ', email='*****@*****.**') new_artist_2.save() new_artist_3 = Artist(artist_name='Omar Mohamud', email='*****@*****.**') new_artist_3.save() new_artist_3 = Artist(artist_name='Aubrey Graham', email='*****@*****.**') new_artist_3.save() new_artwork_1 = Artwork(artwork_name='Drake', price=22.45, artist=1) new_artwork_1.save() new_artwork_2 = Artwork(artwork_name='best code ever', price=2.30, artist=2) new_artwork_2.save() new_artwork_3 = Artwork(artwork_name='Sold Artwork', price=800.9, available=False, artist=2) new_artwork_3.save() new_artwork_4 = Artwork(artwork_name='Please delete', price=900.9, available=False, artist=1) new_artwork_4.save() except Exception as e: ui.message(e)
def find_artist(name): artist = Artist.get_or_none(Artist.name == name) if artist: return artist.id
def show_all_artist(): try: artists = Artist.select() return list(artists) except: return 'Error'