示例#1
0
    def test_get_artist_name(self):

        for en_artist in AmDmTestCase.EN_ARTISTS:
            artist = Artist(en_artist["url"])
            self.assertEqual(artist.name, en_artist["name"])

        for ru_artist in AmDmTestCase.RU_ARTISTS:
            artist = Artist(ru_artist["url"])
            self.assertEqual(artist.name, ru_artist["name"])
示例#2
0
    def test_get_songs(self):

        milky_chance = AmDmTestCase.EN_ARTISTS[2]
        artist = Artist(milky_chance["url"])

        songs = artist.get_songs()

        for song, mc_song in zip(songs, AmDmTestCase.MILKY_CHANCE_SONGS):
            self.assertIsInstance(song, Song)
            self.assertEqual(song.name, mc_song[0])
            self.assertEqual(song.url, mc_song[1])
示例#3
0
def populate_artists():
    for artist in artist_data:
        data = Artist(
            id=artist["id"],
            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"],
            # past_shows = artist["past_shows"],
            # upcoming_shows = artist["upcoming_shows"],
            # past_shows_count = artist["past_shows_count"],
            # upcoming_shows_count = artist["upcoming_shows_count"]
        )
        db.session.add(data)

    id4 = Artist.query.get(4)
    id4.facebook_link = artist_data[0]["facebook_link"]
    id4.website = artist_data[0]["website"]
    id4.seeking_description = artist_data[0]["seeking_description"]
    db.session.add(id4)

    id5 = Artist.query.get(5)
    id5.facebook_link = artist_data[0]["facebook_link"]
    db.session.add(id5)

    db.session.commit()
示例#4
0
def test_get_perf_by_id():
    db.session.add(Song(name="Slippery When Wet"))
    db.session.add(Artist(name="Commodores"))
    db.session.add(Concert(name="Glastonbury"))
    db.session.add(Performance(rating=randint(5, 10), song_id=1, concert_id=1))
    res = client.get("/api/performances/1")
    assert res.json["perf_id"] == 1
示例#5
0
def test_search():
    db.session.add(Song(name="Slippery When Wet"))
    db.session.add(Artist(name="Commodores"))
    db.session.add(Concert(name="Glastonbury"))
    db.session.add(Performance(rating=randint(5, 10), song_id=1, concert_id=1))
    db.session.commit()
    res = search(query="Slippery When Wet", page=1, concert=1)
    assert res.items[0].song.name == "Slippery When Wet"
示例#6
0
def insert_artists():
    artist_1 = Artist(
        id=4,
        name="Guns N Petals",
        city="San Francisco",
        state="CA",
        phone="326-123-5000",
        website="https://www.gunsnpetalsband.com",
        image_link=
        "https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80",
        facebook_link="https://www.facebook.com/GunsNPetals",
        seeking_venue=True,
        seeking_description=
        "Looking for shows to perform at in the San Francisco Bay Area!",
    )

    artist_2 = Artist(
        id=5,
        name="Matt Quevedo",
        city="New York",
        state="NY",
        phone="300-400-5000",
        image_link=
        "https://images.unsplash.com/photo-1495223153807-b916f75de8c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80",
        facebook_link="https://www.facebook.com/mattquevedo923251523",
        seeking_venue=False,
    )

    artist_3 = Artist(
        id=6,
        name="The Wild Sax Band",
        city="San Francisco",
        state="CA",
        phone="432-325-5432",
        image_link=
        "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80",
        facebook_link="https://www.facebook.com/mattquevedo923251523",
        seeking_venue=False,
    )

    db.session.add_all([artist_1, artist_2, artist_3])
    db.session.commit()
示例#7
0
def dummy_artist_data():
    error = False
    try:
        artist_data = [artist_data1, artist_data2, artist_data3]
        for data in artist_data:
            ar = Artist(**data)
            db.session.add(ar)
            db.session.commit()
    except:
        error = True
        db.session.rollback()
        print(f'Artist: {sys.exc_info()}')
    finally:
        db.session.close()
示例#8
0
    def test_get_song(self):

        for en_artist, en_song in zip(AmDmTestCase.EN_ARTISTS,
                                      AmDmTestCase.EN_SONGS):

            artist = Artist(en_artist["url"])
            songs = artist.get_songs()

            chosen_song = songs[en_song["number"] - 1]

            self.assertEqual(chosen_song.name, en_song["name"])
            self.assertEqual(chosen_song.url, en_song["url"])

        for ru_artist, ru_song in zip(AmDmTestCase.RU_ARTISTS,
                                      AmDmTestCase.RU_SONGS):

            artist = Artist(ru_artist["url"])
            songs = artist.get_songs()

            chosen_song = songs[ru_song["number"] - 1]

            self.assertEqual(chosen_song.name, ru_song["name"])
            self.assertEqual(chosen_song.url, ru_song["url"])
示例#9
0
    "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=s["start_time"])
    db.session.add(show)
    db.session.commit()
示例#10
0
    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)
        db.session.add(artist_genre)
    i+=1

for s in shows:
    show = Show(artist_id = s['artist_id'], venue_id = s['venue_id'], start_time = s['start_time'])
    db.session.add(show)

db.session.commit()

示例#11
0
文件: fixtures.py 项目: jdedman/bftw
if __name__ == '__main__':
    fixture_path = 'sample.json'

    print "Dropping tables..."
    db.drop_all()

    print "Creating tables..."
    db.create_all()

    with open(fixture_path) as fixture_file:
        fixtures = json.load(fixture_file)

    for artist in fixtures:
        print 'Creating artist: {}'.format(artist['name'])
        _artist = Artist(name=artist['name'], bio=artist['bio'])

        db.session.add(_artist)

        for album in artist['albums']:
            print ' Creating album: {}'.format(album['name'])
            _album = Album(name=album['name'],
                           artwork_url=album['artwork_url'],
                           artist=_artist)

            db.session.add(_album)

            for song in album['songs']:
                print '     Creating song: {}'.format(song['name'])
                _song = Song(name=song['name'],
                             album=_album,
示例#12
0
    def run(self):
        seed_artists = [{
            "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",
        }, {
            "name":
            "Matt Quevedo",
            "genres":
            "Jazz",
            "city":
            "New York",
            "state":
            "NY",
            "phone":
            "300-400-5000",
            "facebook_link":
            "https://www.facebook.com/mattquevedo923251523",
            "seeking_venue":
            True,
            "seeking_description":
            "I am awesome! Book me now for all your slots",
            "website":
            "https://www.mattyQ.com",
            "image_link":
            "https://images.unsplash.com/photo-1495223153807-b916f75de8c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80",
        }, {
            "name":
            "The Wild Sax Band",
            "genres":
            "Jazz,Classical",
            "city":
            "San Francisco",
            "state":
            "CA",
            "phone":
            "432-325-5432",
            "seeking_venue":
            True,
            "seeking_description":
            "Everyone loves sax, let us prove it to you",
            "website":
            "https://www.wildsax.com",
            "facebook_link":
            "https://www.facebook.com/wildsaxpeople",
            "image_link":
            "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80",
        }]

        for artist_data in seed_artists:
            artist = Artist(
                name=artist_data['name'],
                genres=artist_data['genres'],
                city=artist_data['city'],
                state=artist_data['state'],
                phone=artist_data['phone'],
                website=artist_data['website'],
                facebook_link=artist_data['facebook_link'],
                seeking_venue=artist_data['seeking_venue'],
                seeking_description=artist_data['seeking_description'],
                image_link=artist_data['image_link'])
            print("Adding artist: %s" % artist)
            self.db.session.add(artist)
示例#13
0
def insert_artists():
    data1 = {
        "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",
        "past_shows": [{
            "venue_id": 1,
            "venue_name": "The Musical Hop",
            "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",
            "start_time": "2019-05-21T21:30:00.000Z",
        }],
        "upcoming_shows": [],
        "past_shows_count":
        1,
        "upcoming_shows_count":
        0,
    }
    data2 = {
        "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",
        "past_shows": [{
            "venue_id": 3,
            "venue_name": "Park Square Live Music & Coffee",
            "venue_image_link":
            "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80",
            "start_time": "2019-06-15T23:00:00.000Z",
        }],
        "upcoming_shows": [],
        "past_shows_count":
        1,
        "upcoming_shows_count":
        0,
    }
    data3 = {
        "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",
        "past_shows": [],
        "upcoming_shows": [
            {
                "venue_id": 3,
                "venue_name": "Park Square Live Music & Coffee",
                "venue_image_link":
                "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80",
                "start_time": "2035-04-01T20:00:00.000Z",
            },
            {
                "venue_id": 3,
                "venue_name": "Park Square Live Music & Coffee",
                "venue_image_link":
                "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80",
                "start_time": "2035-04-08T20:00:00.000Z",
            },
            {
                "venue_id": 3,
                "venue_name": "Park Square Live Music & Coffee",
                "venue_image_link":
                "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80",
                "start_time": "2035-04-15T20:00:00.000Z",
            },
        ],
        "past_shows_count":
        0,
        "upcoming_shows_count":
        3,
    }

    try:
        for item in [data1, data2, data3]:
            kwargs = {
                k: v
                for k, v in item.items() if k in Artist.__table__.columns
            }
            row = Artist(**kwargs)
            db.session.add(row)
        db.session.commit()
    except:
        db.session.rollback()
        print("Error!!!!")
    finally:
        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()
示例#15
0
    "phone":
    "432-325-5432",
    "website":
    None,
    "facebook_link":
    None,
    "seeking_venue":
    False,
    "seeking_description":
    None,
    "image_link":
    "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80"
})

for a in artists:
    artist = Artist(**a)
    db.session.add(artist)

#  Shows
#  ----------------------------------------------------------------

shows = ({
    "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,
示例#16
0
print(str(sys.argv))
if len(sys.argv) > 2:
    className = str(sys.argv[2])
    fileName = str(sys.argv[1])
    print()
    with open(fileName, newline='') as csvfile:
        spamreader = csv.reader(csvfile, delimiter=',')
        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:
示例#17
0
文件: demo.py 项目: AhmosGUC/fyyur
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='')
示例#18
0
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()
示例#19
0
from app import db, Artist, Artist_Genre
import sys

# Add artist data
groban = Artist(name='Groban',
                city='New York',
                state='NY',
                phone='212-121-3940',
                website='www.groban.com',
                image_link='www.groban.com/img',
                facebook_link='www.facebook.com/groban')

groban_genre1 = Artist_Genre(genre='rock')
groban_genre2 = Artist_Genre(genre='contemporary')
groban_genre1.artist = groban
groban_genre2.artist = groban

mature_five = Artist(name='Mature 5',
                     city='New York',
                     state='NY',
                     phone='212-304-2399',
                     website='www.maturefive.com',
                     image_link='www.maturefive.com/img',
                     facebook_link='www.facebook.com/mature_five')

mature_five_genre1 = Artist_Genre(genre='pop')
mature_five_genre2 = Artist_Genre(genre='contemporary')

mature_five_genre1.artist = mature_five
mature_five_genre2.artist = mature_five
示例#20
0
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()
示例#21
0
'''

"""

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@localhost:5432/fyyurDB'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)


######## populate artists
artist1 = Artist(id=1, 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(artist1)
db.session.commit()

artist2 = Artist(id=2, 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"
    )
示例#22
0
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']
        except:
            o.seeking_venue = obj['seeking_venue']
示例#23
0
#!/usr/bin/env python

from random import randint

from app import Artist, Concert, Performance, Song, db

print("\n 🌱 seeding db... \n")

db.drop_all()
db.create_all()

artists = [Artist(name="Massive Attack"), Artist(name="Nas")]
for a in artists:
    db.session.add(a)
db.session.commit()

massive_attack = Artist.query.get(1)
nas = Artist.query.get(2)

songs = [
    Song(name="One Love", artist=massive_attack),
    Song(name="One Love", artist=nas),
    Song(name="Protection", artist=massive_attack),
    Song(name="Black Bond", artist=nas),
    Song(name="The World is Yours", artist=nas),
    Song(name="Bye Baby", artist=nas),
]
for s in songs:
    db.session.add(s)
db.session.commit()
示例#24
0
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()
示例#25
0
def gen_many_artists(num_artists=10,
                     name_prefix="artist_",
                     city="San Francisco",
                     state="CA",
                     genre="Other"):
    artists = []
    for i in range(1, num_artists):
        new_artist = Artist()
        new_artist.name = f'{name_prefix}{i}'
        new_artist.genre.append(ArtistGenre(name=genre))
        new_artist.city = city
        new_artist.state = state
        new_artist.phone = "555-555-5555"
        new_artist.website = "https://www.{name_prefix}{i}.com"
        new_artist.facebook_link = "https://www.facebook.com/{name_prefix}{i}"
        new_artist.seeking_venue = False
        new_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"
        new_artist.listed_time = datetime.datetime.utcnow()
        artists.append(new_artist)

    db.session.add_all(artists)
    db.session.commit()
示例#26
0
db.session.commit()

#---------------------------------#
# Add Artists
#---------------------------------#
a1 = Artist(
    **{
        "name":
        "Guns N Petals",
        "genres": [genres[16]],
        "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",
    })

a2 = Artist(
    **{
        "name":
        "Matt Quevedo",
示例#27
0
import array
from app import db, Artist

artist_1 = Artist(name="Guns N Petals")

artist_1.genres = ["Rock n Roll"]
artist_1.city = "San Francisco"
artist_1.state = "CA"
artist_1.phone = "326-123-5000"
artist_1.website = "https://www.gunsnpetalsband.com"
artist_1.facebook_link = "https://www.facebook.com/GunsNPetals"
artist_1.seeking_venue = True
artist_1.seeking_description = "Looking for shows to perform at in the San Francisco Bay Area!"
artist_1.image_link = "https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80"

artist_2 = Artist(name="Matt Quevedo")
artist_2.genres = ["Jazz"]
artist_2.city = "New York"
artist_2.state = "NY"
artist_2.phone = "300-400-5000"
artist_2.facebook_link = "https://www.facebook.com/mattquevedo923251523"
artist_2.seeking_venue = False
artist_2.image_link = "https://images.unsplash.com/photo-1495223153807-b916f75de8c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80"

artist_3 = Artist(name="The Wild Sax Band")
artist_3.genres = ["Jazz", "Classical"]
artist_3.city = "San Francisco"
artist_3.state = "CA"
artist_3.phone = "432-325-5432"
artist_3.seeking_venue = False
artist_3.image_link = "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80"
示例#28
0
def _get_artist(name="testartist"):
    return Artist(name=name, unique_name="unique name artist test")
示例#29
0
    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',
)

artist = Artist(
    name="Justin Beiberlake",
    genres=["Jazz", "Reggae", "Swing", "Classical", "Folk"],
    city='Fakesville',
    state="CA",
    phone='555-555-5556',
    website='https://www.youtube.com/watch?v=dQw4w9WgXcQ',
    facebook_link='https://www.facebook.com/joeexotic',
    image_link="https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80",
    seeking_venue=True,
    seeking_description='Fake it till you make it baby!'
)

artist2 = Artist(
    name="Chris Cornelton",
    genres=["Swing", "Classical", "Folk"],
    city='Fakesville',
    state="CA",
    phone='555-555-5456',
    website='https://www.youtube.com/watch?v=dQw4w9WgXcQ',
    facebook_link='https://www.facebook.com/joeexotic',
    image_link="https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80",