def gen_many_venues(num_venues=10, name_prefix="venue_", city="San Francisco", state="CA", genre="Other"): venues = [] for i in range(1, num_venues): new_venue = Venue() new_venue.name = f'{name_prefix}{i}' new_venue.genre.append(VenueGenre(name=genre)) new_venue.city = city new_venue.state = state new_venue.address = f"{i} {name_prefix}" new_venue.phone = "555-555-5555" new_venue.website_link = f"https://www.{name_prefix}{i}.com" new_venue.facebook_link = f"https://www.facebook.com/{name_prefix}{i}" new_venue.seeking_talent = False new_venue.image_link = "https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60" new_venue.listed_time = datetime.datetime.utcnow() venues.append(new_venue) db.session.add_all(venues) db.session.commit()
import array from app import db, Venue venue_1 = Venue(name="The Musical Hop") venue_1.genres = ["Jazz", "Reggae", "Swing", "Classical", "Folk"] venue_1.address = "1015 Folsom Street" venue_1.city = "San Francisco" venue_1.state = "CA" venue_1.phone = "123-123-1234" venue_1.website = "https://www.themusicalhop.com" venue_1.facebook_link = "https://www.facebook.com/TheMusicalHop" venue_1.seeking_talent = True venue_1.seeking_description = "We are on the lookout for a local artist to play every two weeks. Please call us." venue_1.image_link = "https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60" venue_2 = Venue(name="The Dueling Pianos Bar") venue_2.genres = ["Classical", "R&B", "Hip-Hop"] venue_2.address = "335 Delancey Street" venue_2.city = "New York" venue_2.state = "NY" venue_2.phone = "914-003-1132" venue_2.website = "https://www.theduelingpianos.com" venue_2.facebook_link = "https://www.facebook.com/theduelingpianos" venue_2.seeking_talent = False venue_2.image_link = "https://images.unsplash.com/photo-1497032205916-ac775f0649ae?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" venue_3 = Venue(name="Park Square Live Music & Coffee") venue_3.genres = ["Rock n Roll", "Jazz", "Classical", "Folk"] venue_3.address = "34 Whiskey Moore Ave" venue_3.city = "San Francisco" venue_3.state = "CA"
def gen_specific_data(): artist0 = Artist() artist0.name = "Guns N Petals" artist0.genre.append(ArtistGenre(name="Rock N Roll")) artist0.city = "San Francisco" artist0.state = "CA" artist0.phone = "326-123-5000" artist0.website = "https://www.gunspetalsband.com" artist0.facebook_link = "https://www.facebook.com/GunsNPetals" artist0.seeking_venue = True artist0.seeking_description = "Looking for shows to perform at in the San Francisco Bay Area!" artist0.image_link = "https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80" artist0.listed_time = datetime.datetime.utcnow() artist1 = Artist() artist1.name = "Matt Quevedo" artist1.genre.append(ArtistGenre(name="Jazz")) artist1.city = "New York" artist1.state = "NY" artist1.phone = "300-400-5000" artist1.facebook_link = "https://www.facebook.com/mattquevedo923251523" artist1.seeking_venue = False artist1.image_link = "https://images.unsplash.com/photo-1495223153807-b916f75de8c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80" artist1.listed_time = datetime.datetime.utcnow() artist2 = Artist() artist2.name = "The Wild Sax Band" artist2.genre.append(ArtistGenre(name="Jazz")) artist2.genre.append(ArtistGenre(name="Classical")) artist2.city = "San Francisco" artist2.state = "CA" artist2.phone = "432-325-5432" artist2.seeking_venue = False artist2.image_link = "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80" artist2.listed_time = datetime.datetime.utcnow() artist3 = Artist() artist3.name = "Mo Jo Yo Jo" artist3.genre.append(ArtistGenre(name="Hip Hop Anonymous")) artist3.city = "Cool Cats" artist3.state = "CA" artist3.phone = "555-555-5000" artist3.website = "https://www.hoptothetop.com" artist3.facebook_link = "https://www.facebook.com/mojoyojo" artist3.seeking_venue = True artist3.seeking_description = "Looking for shows to perform at in Cool Cats California!" artist3.image_link = "https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80" artist3.listed_time = datetime.datetime.utcnow() db.session.add(artist0) db.session.add(artist1) db.session.add(artist2) db.session.add(artist3) db.session.commit() venue0 = Venue() venue0.city = "San Francisco" venue0.state = "CA" venue0.phone = "123-123-1234" venue0.name = "The Musical Hop" venue0.genre.append(VenueGenre(name="Rock N Roll")) venue0.genre.append(VenueGenre(name="Jazz")) venue0.genre.append(VenueGenre(name="Classical")) venue0.address = "1015 Folsom Street" venue0.seeking_talent = True venue0.seeking_talent_desc = "We don't need talent, we need legends" venue0.listed_time = datetime.datetime.utcnow() venue1 = Venue() venue1.city = "San Francisco" venue1.state = "CA" venue1.phone = "415-000-1234" venue1.name = "Park Square Live Music & Coffee", venue1.genre.append(VenueGenre(name="Rap")) venue1.genre.append(VenueGenre(name="Rock N Roll")) venue1.genre.append(VenueGenre(name="Punk")) venue1.address = "34 Whiskey Moore Ave" venue1.seeking_talent = False venue1.listed_time = datetime.datetime.utcnow() venue2 = Venue() venue2.city = "New York" venue2.state = "NY" venue2.phone = "914-003-1132" venue2.name = "The Dueling Pianos Bar" venue2.genre.append(VenueGenre(name="Soul")) venue2.address = "335 Delancey Street" venue2.seeking_talent = True venue2.seeking_talent_desc = "Yo we need some talent in this hizouse" venue2.listed_time = datetime.datetime.utcnow() venue3 = Venue() venue3.city = "Oakland" venue3.state = "CA" venue3.phone = "415-555-5555" venue3.name = "Oakland Convention Center", venue3.genre.append(VenueGenre(name="Alternative")) venue3.address = "6824 Main St" venue3.seeking_talent = False venue3.listed_time = datetime.datetime.utcnow() db.session.add(venue0) db.session.add(venue1) db.session.add(venue2) db.session.add(venue3) db.session.commit() show0 = Show() show0.artist_id = Artist.query.first().id show0.venue_id = Venue.query.first().id show0.start_time = datetime.datetime.fromisoformat( '2020-04-05T21:30:00.000') db.session.add(show0) db.session.commit()
db.session.query(ArtistGenres).delete() db.session.query(VenueGenres).delete() db.session.query(Artist).delete() db.session.query(Venue).delete() for i, x in enumerate([venues, artists]): for obj in x: if i == 0: o = Venue() if i == 1: o = Artist() o.name = obj['name'] try: o.address = obj['address'] except: pass o.city = obj['city'] o.state = obj['state'] o.phone = obj['phone'] o.website = obj.get('website') o.facebook_link = obj.get('facebook_link') try: o.seeking_talent = obj['seeking_talent'] except: o.seeking_venue = obj['seeking_venue'] o.seeking_description = obj.get('seeking_description') o.image_link = obj['image_link'] for genre in obj['genres']: