def insert_venue_data(venues): for item in venues: venue = Venue(name=item.get("name"), address=item.get("address"), phone=item.get("phone"), website=item.get("website"), image_link=item.get("image_link"), facebook_link=item.get("facebook_link"), seeking_talent=item.get("seeking_talent"), seeking_description=item.get("seeking_description")) gener_list = [Gener(gener=i) for i in item.get("genres")] state = State.query.filter_by(state=item.get("state")).first() city = City.query.filter_by(city=item.get("city")).first() if state: if city: venue.city_id = city.id else: city = City(city=item.get("city")) city.state_id = state.id else: state = State(state=item.get("state")) city = City(city=item.get("city")) city._state = state venue._city = city venue.geners = gener_list db.session.add(venue) db.session.commit() print("Inserted {}".format(item.get("name"))) return print("All Venue Inserted")
def populate_venue_distance_data(venue_dict): for venue in venue_dict: try: rt_commonwealth_corrected = float( venue_dict[venue]['round_trip_commonwealth']) except ValueError as ve: rt_commonwealth_corrected = None except TypeError as te: rt_commonwealth_corrected = None try: rt_dry_bridge_corrected = float( venue_dict[venue]['round_trip_dry_br']) except ValueError as ve: rt_dry_bridge_corrected = None except TypeError as te: rt_dry_bridge_corrected = None add_venue = Venue(venue=venue, rt_miles_from_commonwealth=rt_commonwealth_corrected, rt_miles_from_dry_bridge=rt_dry_bridge_corrected, city=venue_dict[venue]['city']) db.session.add(add_venue) db.session.commit()
def populate_venues(): for venue in venues_data: data = Venue( id=venue["id"], name=venue["name"], genres=venue["genres"], address=venue["address"], city=venue["city"], state=venue["state"], phone=venue["phone"], website=venue["website"], facebook_link=venue["facebook_link"], seeking_talent=venue["seeking_talent"], # seeking_description = venue["seeking_description"], image_link=venue["image_link"], # past_shows = venue["past_shows"], # upcoming_shows = venue["upcoming_shows"], # past_shows_count = venue["past_shows_count"], # upcoming_shows_count = venue["upcoming_shows_count"] ) db.session.add(data) id1 = Venue.query.get(1) id1.seeking_description = artist_data[0]["seeking_description"] db.session.add(id1) db.session.commit()
def insert_venues(): venue_1 = Venue( id=1, name="The Musical Hop", city="San Francisco", state="CA", address="1015 Folsom Street", phone="123-123-1234", image_link= "https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", facebook_link="https://www.facebook.com/TheMusicalHop", website="https://www.themusicalhop.com", seeking_talent=True, seeking_description= "We are on the lookout for a local artist to play every two weeks. Please call us.", ) venue_2 = Venue( id=2, name="The Dueling Pianos Bar", city="New York", state="NY", address="335 Delancey Street", phone="914-003-1132", image_link= "https://images.unsplash.com/photo-1497032205916-ac775f0649ae?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80", facebook_link="https://www.facebook.com/theduelingpianos", website="https://www.theduelingpianos.com", seeking_talent=False, ) venue_3 = Venue( id=3, name="Park Square Live Music & Coffee", city="San Francisco", state="CA", address="34 Whiskey Moore Ave", phone="415-000-1234", image_link= "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80", facebook_link="https://www.facebook.com/ParkSquareLiveMusicAndCoffee", website="https://www.parksquarelivemusicandcoffee.com", seeking_talent=False, ) db.session.add_all([venue_1, venue_2, venue_3]) db.session.commit()
def dummy_venue_data(): error = False try: venue_data = [venue_data1, venue_data2, venue_data3] for data in venue_data: vn = Venue(**data) db.session.add(vn) db.session.commit() except: error = True db.session.rollback() print(f'Venue: {sys.exc_info()}') finally: db.session.close()
def run(self): venue1 = Venue( name="The Musical Hop", address="1015 Folsom Street", city="San Francisco", state="CA", phone="123-123-1234", website="https://www.themusicalhop.com", facebook_link="https://www.facebook.com/TheMusicalHop", seeking_talent=True, seeking_description= "We are on the lookout for a local artist to play every two weeks. Please call us.", image_link= "https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60" )
def run(self): seed_venues = [{ "name": "The Musical Hop", "genres": ["Jazz", "Reggae", "Swing", "Classical", "Folk"], "address": "1015 Folsom Street", "city": "San Francisco", "state": "CA", "phone": "123-123-1234", "website": "https://www.themusicalhop.com", "facebook_link": "https://www.facebook.com/TheMusicalHop", "seeking_talent": True, "seeking_description": "We are on the lookout for a local artist to play every two weeks. Please call us.", "image_link": "https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60" }, { "name": "The Dueling Pianos Bar", "genres": ["Classical", "R&B", "Hip-Hop"], "address": "335 Delancey Street", "city": "New York", "state": "NY", "phone": "914-003-1132", "website": "https://www.theduelingpianos.com", "facebook_link": "https://www.facebook.com/theduelingpianos", "seeking_talent": True, "seeking_description": "We are on the lookout for a local artist to play every two weeks. Please call us.", "image_link": "https://images.unsplash.com/photo-1497032205916-ac775f0649ae?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80", }, { "name": "Park Square Live Music & Coffee", "genres": ["Rock n Roll", "Jazz", "Classical", "Folk"], "address": "34 Whiskey Moore Ave", "city": "San Francisco", "state": "CA", "phone": "415-000-1234", "website": "https://www.parksquarelivemusicandcoffee.com", "facebook_link": "https://www.facebook.com/ParkSquareLiveMusicAndCoffee", "seeking_talent": True, "seeking_description": "We are on the lookout for a local artist to play every two weeks. Please call us.", "image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80", }] for venue_data in seed_venues: venue = Venue(name=venue_data['name'], genres=venue_data['genres'], address=venue_data['address'], city=venue_data['city'], state=venue_data['state'], phone=venue_data['phone'], website=venue_data['website'], facebook_link=venue_data['facebook_link'], seeking_talent=venue_data['seeking_talent'], seeking_description=venue_data['seeking_description'], image_link=venue_data['image_link']) print("Adding venue: %s" % venue) self.db.session.add(venue)
from app import db, Venue, Venue_Genre import sys jezebel_lair = Venue(name='Jezebel\'s Lair', city='New York', state='NY', address='18E 58th St.', website='www.jezeli.com', phone='212-304-3394', image_link='www.jezeli.com/pic', facebook_link='www.facebook.com/jezebel_lair') jezebel_lair_genre1 = Venue_Genre(genre='Indie') jezebel_lair_genre2 = Venue_Genre(genre='Jazz') jezebel_lair_genre1.venue = jezebel_lair jezebel_lair_genre2.venue = jezebel_lair honkin_tonk = Venue(name='The Honkin Tonk Pub', city='Nashville', state='TN', address='394 Brooksfield Rd.', website='www.honkintonkpub.com', phone='615-349-1239', image_link='www.honkintonkpub.com/pic', facebook_link='www.facebook.com/honkin_tonk') honkin_tonk_genre1 = Venue_Genre(genre='Country') honkin_tonk_genre2 = Venue_Genre(genre='Rock') honkin_tonk_genre1.venue = honkin_tonk honkin_tonk_genre2.venue = honkin_tonk
"start_time": "2035-04-01T20:00:00.000Z" }, { "venue_id": 3, "artist_id": 6, "start_time": "2035-04-08T20:00:00.000Z" }, { "venue_id": 3, "artist_id": 6, "start_time": "2035-04-15T20:00:00.000Z" }] # ---------------------------------------------------------------- # Load Data into DB # ---------------------------------------------------------------- for v in venues_data: venue = Venue(id=v["id"], name=v["name"]) for key, value in v.items(): setattr(venue, key, value) db.session.add(venue) db.session.commit() for a in artists_data: artist = Artist(id=a["id"], name=a["name"]) for key, value in a.items(): setattr(artist, key, value) db.session.add(artist) db.session.commit() for s in shows_data: show = Show(venue_id=s["venue_id"], artist_id=s["artist_id"],
"start_time": "2035-04-15T20:00:00.000Z" }] db.drop_all() db.create_all() i = 1 for g in genres: genre = Genre(name=g) db.session.add(genre) db.session.commit() for v in venues: venue = Venue(name=v['name'], address=v['address'], city=v['city'], state=v['state'], phone=v['phone'], website=v['website'], facebook_link=v['facebook_link'], seeking_talent=v['seeking_talent'], image_link=v['image_link'] ) db.session.add(venue) for vg in v['genres']: vg_id = Genre.query.filter_by(name=vg).first().id # print(vg_id.id) venue_genre = Venue_Genre(venue_id = i, genre_id = vg_id) db.session.add(venue_genre) i+=1 i = 1 for a in artists: artist = Artist(name=a['name'], city=a['city'], state=a['state'], phone=a['phone'], website=a['website'], seeking_venue=a['seeking_venue'], image_link=a['image_link'] ) db.session.add(artist) for ag in a['genres']: ag_id = Genre.query.filter_by(name=ag).first().id artist_genre = Artist_Genre(artist_id = i, genre_id = vg_id)
def insert_venues(): data1 = { # "id": 1, "name": "The Musical Hop", "genres": ["Jazz", "Reggae", "Swing", "Classical", "Folk"], "address": "1015 Folsom Street", "city": "San Francisco", "state": "CA", "phone": "123-123-1234", "website": "https://www.themusicalhop.com", "facebook_link": "https://www.facebook.com/TheMusicalHop", "seeking_talent": True, "seeking_description": "We are on the lookout for a local artist to play every two weeks. Please call us.", "image_link": "https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", "past_shows": [{ "artist_id": 4, "artist_name": "Guns N Petals", "artist_image_link": "https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80", "start_time": "2019-05-21T21:30:00.000Z", }], "upcoming_shows": [], "past_shows_count": 1, "upcoming_shows_count": 0, } data2 = { # "id": 2, "name": "The Dueling Pianos Bar", "genres": ["Classical", "R&B", "Hip-Hop"], "address": "335 Delancey Street", "city": "New York", "state": "NY", "phone": "914-003-1132", "website": "https://www.theduelingpianos.com", "facebook_link": "https://www.facebook.com/theduelingpianos", "seeking_talent": False, "image_link": "https://images.unsplash.com/photo-1497032205916-ac775f0649ae?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80", "past_shows": [], "upcoming_shows": [], "past_shows_count": 0, "upcoming_shows_count": 0, } data3 = { # "id": 3, "name": "Park Square Live Music & Coffee", "genres": ["Rock n Roll", "Jazz", "Classical", "Folk"], "address": "34 Whiskey Moore Ave", "city": "San Francisco", "state": "CA", "phone": "415-000-1234", "website": "https://www.parksquarelivemusicandcoffee.com", "facebook_link": "https://www.facebook.com/ParkSquareLiveMusicAndCoffee", "seeking_talent": False, "image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80", "past_shows": [{ "artist_id": 5, "artist_name": "Matt Quevedo", "artist_image_link": "https://images.unsplash.com/photo-1495223153807-b916f75de8c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80", "start_time": "2019-06-15T23:00:00.000Z", }], "upcoming_shows": [ { "artist_id": 6, "artist_name": "The Wild Sax Band", "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", "start_time": "2035-04-01T20:00:00.000Z", }, { "artist_id": 6, "artist_name": "The Wild Sax Band", "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", "start_time": "2035-04-08T20:00:00.000Z", }, { "artist_id": 6, "artist_name": "The Wild Sax Band", "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", "start_time": "2035-04-15T20:00:00.000Z", }, ], "past_shows_count": 1, "upcoming_shows_count": 1, } try: for item in [data1, data2, data3]: kwargs = { k: v for k, v in item.items() if k in Venue.__table__.columns } row = Venue(**kwargs) db.session.add(row) db.session.commit() except: db.session.rollback() print("Error!!!! in venue insertion") finally: db.session.close()
from app import Venue, Artist, Show, db # Add Venue db.session.add_all([ Venue( name="The Musical Hop", city="San Francisco", state="CA", address="1015 Folsom Street", phone="123-123-1234", genres=["Jazz", "Reggae", "Swing", "Classical", "Folk"], facebook_link="https://www.facebook.com/TheMusicalHop", seeking_talent=True, website="https://www.themusicalhop.com", seeking_description= "We are on the lookout for a local artist to play every two weeks. Please call us.", 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( name="The Dueling Pianos Bar", city="New York", state="NY", address="335 Delancey Street", phone="914-003-1132", genres=["Classical", "R&B", "Hip-Hop"], facebook_link="https://www.facebook.com/theduelingpianos", seeking_talent=False, website="https://www.theduelingpianos.com", image_link= "https://images.unsplash.com/photo-1497032205916-ac775f0649ae?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80"
def main(): with open('seed_data.json') as json_file: data = json.load(json_file) # artists = map(artist_mapper, data['artists']) print("Seeding...") try: for artist in data['artists']: past_days = random.randrange(0, 20) created_at = datetime.now() - timedelta(days=past_days) artist_obj = Artist( name=artist['name'], genres=artist["genres"], city=artist["city"], state=artist['state'], phone=artist['phone'], website=artist['website'], facebook_link=artist['facebook_link'], seeking_venue=artist['seeking_venue'], seeking_description=artist['seeking_description'], image_link=artist['image_link'], created_at=created_at, ) db.session.add(artist_obj) db.session.commit() for venue in data['venues']: past_days = random.randrange(0, 20) created_at = datetime.now() - timedelta(days=past_days) venue_obj = Venue( name=venue['name'], genres=venue["genres"], city=venue["city"], state=venue['state'], address=venue['address'], phone=venue['phone'], website=venue['website'], facebook_link=venue['facebook_link'], seeking_talent=venue['seeking_talent'], seeking_description=venue['seeking_description'], image_link=venue['image_link'], created_at=created_at, ) db.session.add(venue_obj) for i in range(10): past_days = random.randrange(-3, 3) start_time = datetime.now() + timedelta(days=past_days) show_obj = Show( artist_id=random.randrange(1, 20), venue_id=random.randrange(1, 20), start_time=start_time, ) db.session.add(show_obj) db.session.commit() for i in range(10): past_days = random.randrange(-3, 3) duration = random.randrange(2, 20) start_time = datetime.now() + timedelta(days=past_days) end_time = start_time + timedelta(days=duration) show_obj = Show( artist_id=random.randrange(1, 20), venue_id=random.randrange(1, 20), start_time=start_time, ) db.session.add(show_obj) db.session.commit() print("Done seeding.") except: db.session.rollback() print(sys.exc_info()) print("Error seeding.") finally: db.session.close()
from app import db, Venue, Artist, Show v1 = Venue(name='Dor Ri Mi', city='New York', state='NY', address='53', phone='24008200', genres='jazz', image_link='https://picsum.photos/200/300', facebook_link='https://www.facebook.com/HeshamAhmos', website_link='https://www.facebook.com/HeshamAhmos', seeking_talent=True, seeking_description='yes we do') a1 = Artist(name='GUNS N PETALS', city='San Francisco', state='CA', phone=' 326-123-5000', genres='ROCK N ROLL', image_link='https://picsum.photos/200/300', facebook_link='https://www.facebook.com/HeshamAhmos', website_link='https://www.facebook.com/HeshamAhmos', seeking_venue=True, seeking_description='yes we do') s1 = Show(start_time='')
image_link = request.form['image_link'] seeking_talent = False if 'seeking_talent' in request.form: seeking_talent = True seeking_description = " " if 'seeking_description' in request.form: seeking_description = request.form['seeking_description'] image_link = request.form['image_link'] #if location does not exist in Location based on city and state, #create new record, return id then insert to table location_id = get_or_create_loc(city, state, data_type="venue") print(location_id) new_venue = Venue(name = name, location_id = location_id, phone = phone , image_link = image_link, facebook_link = facebook_link, address = address, website = website , seeking_talent = seeking_talent, seeking_description = seeking_description) db.session.add(new_venue) db.session.flush() for i in genres: genres_query = db.session.query(Genre.id, Genre.name).filter(Genre.name.ilike(i)).all()[0] newVenueGenre = VenueGenre(venue_id = new_venue.id , genre_id = genres_query.id) #VenueGenre.insert(newVenueGenre) db.session.add(newVenueGenre) db.session.commit() #location_query = db.session.query(Location.id, Location.city, Location.state).join(Venue, Location.id == Venue.location_id).filter(Location.city.ilike(city)).filter(Location.state.ilike(state)).limit(1).all()[0] #new_venue = Venue(name = name, location_id = location_query.id, phone = phone , image_link = image_link, facebook_link = facebook_link, address = address, website = website , seeking_talent = seeking_talent, seeking_description = seeking_description) #website
#---------------------------------# # Add Venues #---------------------------------# v1 = Venue( **{ "name": "The Musical Hop", "genres": [genres[i] for i in [10, 15, 2, 5]], "address": "1015 Folsom Street", "city": "San Francisco", "state": "CA", "phone": "123-123-1234", "website": "https://www.themusicalhop.com", "facebook_link": "https://www.facebook.com/TheMusicalHop", "seeking_talent": True, "seeking_description": "We are on the lookout for a local artist to play every two weeks. Please call us.", "image_link": "https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", }) v2 = Venue( **{ "name":
def main(): db.create_all() db.session.add( Venue( name='The Musical Hop', genres=['Jazz', 'Reggae', 'Swing', 'Classical', 'Folk'], address='1015 Folsom Street', city='San Francisco', state='CA', phone='123-123-1234', website='https://www.themusicalhop.com', facebook_link='https://www.facebook.com/TheMusicalHop', seeking_talent=True, seeking_description= 'We are on the lookout for a local artist to play every two weeks. Please call us.', image_link= 'https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60', )) db.session.add( Venue( name='The Dueling Pianos Bar', genres=['Classical', 'R&B', 'Hip-Hop'], address='335 Delancey Street', city='New York', state='NY', phone='914-003-1132', website='https://www.theduelingpianos.com', facebook_link='https://www.facebook.com/theduelingpianos', seeking_talent=False, image_link= 'https://images.unsplash.com/photo-1497032205916-ac775f0649ae?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80', )) db.session.add( Venue( name='Park Square Live Music & Coffee', genres=['Rock n Roll', 'Jazz', 'Classical', 'Folk'], address='34 Whiskey Moore Ave', city='San Francisco', state='CA', phone='415-000-1234', website='https://www.parksquarelivemusicandcoffee.com', facebook_link= 'https://www.facebook.com/ParkSquareLiveMusicAndCoffee', seeking_talent=False, image_link= 'https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80', )) db.session.add( Artist( name='Guns N Petals', genres=['Rock n Roll'], city='San Francisco', state='CA', phone='326-123-5000', website='https://www.gunsnpetalsband.com', facebook_link='https://www.facebook.com/GunsNPetals', seeking_venue=True, seeking_description= 'Looking for shows to perform at in the San Francisco Bay Area!', image_link= 'https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80', )) db.session.add( Artist( name='Matt Quevedo', genres=['Jazz'], city='New York', state='NY', phone='300-400-5000', facebook_link='https://www.facebook.com/mattquevedo923251523', seeking_venue=False, image_link= 'https://images.unsplash.com/photo-1495223153807-b916f75de8c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80', )) db.session.add( Artist( name='The Wild Sax Band', genres=['Jazz', 'Classical'], city='San Francisco', state='CA', phone='432-325-5432', seeking_venue=False, image_link= 'https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80', )) db.session.add( Show(venue_id=1, artist_id=1, start_time='2019-05-21 09:30:00 PM')) db.session.add( Show(venue_id=3, artist_id=2, start_time='2019-06-15 11:00:00 PM')) db.session.add( Show(venue_id=3, artist_id=3, start_time='2021-04-01 08:00:00 PM')) db.session.add( Show(venue_id=3, artist_id=3, start_time='2021-04-08 08:00:00 PM')) db.session.add( Show(venue_id=3, artist_id=3, start_time='2021-04-15 08:00:00 PM')) db.session.commit() db.session.close()
def add_initial_data(): # Add initial Venue datapoints venue1 = { "id": 1, "name": "The Musical Hop", "genres": "Jazz, Reggae, Swing, Classical, Folk", "address": "1015 Folsom Street", "city": "San Francisco", "state": "CA", "phone": "123-123-1234", "website": "https://www.themusicalhop.com", "facebook_link": "https://www.facebook.com/TheMusicalHop", "seeking_talent": True, "seeking_description": "We are on the lookout for a local artist to play every two weeks. Please call us.", "image_link": "https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60" } venue2 = { "id": 2, "name": "The Dueling Pianos Bar", "genres": "Classical, R&B, Hip-Hop", "address": "335 Delancey Street", "city": "New York", "state": "NY", "phone": "914-003-1132", "website": "https://www.theduelingpianos.com", "facebook_link": "https://www.facebook.com/theduelingpianos", "seeking_talent": False, "image_link": "https://images.unsplash.com/photo-1497032205916-ac775f0649ae?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" } venue3 = { "id": 3, "name": "Park Square Live Music & Coffee", "genres": "Rock n Roll, Jazz, Classical, Folk", "address": "34 Whiskey Moore Ave", "city": "San Francisco", "state": "CA", "phone": "415-000-1234", "website": "https://www.parksquarelivemusicandcoffee.com", "facebook_link": "https://www.facebook.com/ParkSquareLiveMusicAndCoffee", "seeking_talent": False, "image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80" } artist1 = { "id": 4, "name": "Guns N Petals", "genres": "Rock n Roll", "city": "San Francisco", "state": "CA", "phone": "326-123-5000", "website": "https://www.gunsnpetalsband.com", "facebook_link": "https://www.facebook.com/GunsNPetals", "seeking_venue": True, "seeking_description": "Looking for shows to perform at in the San Francisco Bay Area!", "image_link": "https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80" } artist2 = { "id": 5, "name": "Matt Quevedo", "genres": "Jazz", "city": "New York", "state": "NY", "phone": "300-400-5000", "facebook_link": "https://www.facebook.com/mattquevedo923251523", "seeking_venue": False, "image_link": "https://images.unsplash.com/photo-1495223153807-b916f75de8c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80" } artist3 = { "id": 6, "name": "The Wild Sax Band", "genres": ["Jazz", "Classical"], "city": "San Francisco", "state": "CA", "phone": "432-325-5432", "seeking_venue": False, "image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80" } show_data = [{ "venue_id": 1, "artist_id": 4, "start_time": "2019-05-21T21:30:00.000Z" }, { "venue_id": 3, "artist_id": 5, "start_time": "2019-06-15T23:00:00.000Z" }, { "venue_id": 3, "artist_id": 6, "start_time": "2035-04-01T20:00:00.000Z" }, { "venue_id": 3, "artist_id": 6, "start_time": "2035-04-08T20:00:00.000Z" }, { "venue_id": 3, "artist_id": 6, "start_time": "2035-04-15T20:00:00.000Z" }] for venue in [venue1, venue2, venue3]: venue_record = Venue(**venue) db.session.add(venue_record) for artist in [artist1, artist2, artist3]: artist_record = Artist(**artist) db.session.add(artist_record) for show in show_data: show_record = Show(**show) db.session.add(show_record) db.session.commit()
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()
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()
import app from app import Venue, Artist, db cbg = Venue(name='CBGB', city='New York City', state='New York', address='315 Bowery', phone='7182328764') b = Venue(name='Punk City', city='Seattle', state='New York', address='315 Bowery', phone='7182328764') c = Venue(name='The Unicorn', city='Seattle', state='Washington', address='115 5th Ave', phone='2163238721') d = Venue(name='The Jefferson', city='San Francisco', state='California', address='1032 Polk St', phone='4153435678') e = Venue(name='Ambraisia', city='Portland', state='Oregon', address='81 Main St', phone='7274159000') f = Venue(name='Gorge Amphitheatre', city='Seattle', state='Washington',
print('here') try: for row in spamreader: print(row) print(className) if className == 'artist': x = Artist(id=row[0], name=row[1], city=row[2], state=row[3], phone=row[4]) db.session.add(x) elif className == "venue": x = Venue(id=row[0], name=row[1], city=row[2], state=row[3], address=row[4], phone=row[5], image_link=row[6]) db.session.add(x) db.session.commit() except: print("f****d up") db.session.rollback() finally: db.session.close() else: print("You forgot to add the file of the csv and the direction")
from app import db, Venue, Artist, Show, ArtistGenres, VenueGenres, GenreEnum, StateEnum from data.venues import * from data.artists import * from data.shows import * db.session.query(Show).delete() 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']
"phone": "415-000-1234", "website": "https://www.parksquarelivemusicandcoffee.com", "facebook_link": "https://www.facebook.com/ParkSquareLiveMusicAndCoffee", "seeking_talent": False, "seeking_description": None, "image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80" }) for v in venues: venue = Venue(**v) db.session.add(venue) # Artists # ---------------------------------------------------------------- artists = ({ "id": 4, "name": "Guns N Petals", "city": "San Francisco", "state": "CA", "phone":
from app import Show, Artist, Venue from datetime import datetime from app import db venue = Venue( name='The Fake Bar', genres=["Jazz", "Reggae", "Swing", "Classical", "Folk"], address='555 Fake Drive', city='Fakesville', state='CA', phone='555-555-5555', website='https://www.youtube.com/watch?v=dQw4w9WgXcQ', facebook_link='https://www.facebook.com/joeexotic', seeking_talent=True, seeking_description='Fake it till you make it baby!', image_link='https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60', ) venue2 = Venue( name='The Faker Bar', genres=["Jazz", "Folk"], address='555 Faker Drive', city='Coolville', state='CA', phone='666-666-6666', website='https://www.youtube.com/watch?v=dQw4w9WgXcQ', facebook_link='https://www.facebook.com/joeexotic', seeking_talent=False, seeking_description='Noice!', image_link='https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60', )