Example #1
0
class Album(db.Model):
    __tablename__ = 'albums'
    id = db.Column(db.Integer, primary_key=True)
    spotify_id = db.Column(db.String(100))
    name = db.Column(db.String(100))
    release_date = db.Column(db.String(100))
    artist_id = db.Column(db.Integer, db.ForeignKey('artists.id'))
    artist = db.relationship('Artist', back_populates='albums')
    tracks = db.relationship('Track', back_populates='album')
Example #2
0
class Playlist(db.Model):
    __tablename__ = 'playlists'
    id = db.Column(db.Integer, primary_key=True)
    spotify_id = db.Column(db.String(100))
    name = db.Column(db.String(100))
    tracks = db.relationship('Track',
                             secondary='playlist_tracks',
                             back_populates='playlists')
    genre_id = db.Column(db.Integer, db.ForeignKey('genres.id'))
    genre = db.relationship('Genre', back_populates='playlists')
Example #3
0
class Artist(db.Model):
    __tablename__ = 'artists'
    id = db.Column(db.Integer, primary_key=True)
    spotify_id = db.Column(db.String(100))
    name = db.Column(db.String(100))
    artist_popularity = db.Column(db.Integer)
    followers = db.Column(db.Integer)
    tracks = db.relationship('Track', back_populates='artist')
    albums = db.relationship('Album', back_populates='artist')
    genre = db.relationship('Genre', back_populates='artists')
    genre_id = db.Column(db.Integer, db.ForeignKey('genres.id'))
Example #4
0
class Feature(db.Model):
    __tablename__ = 'features'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100))
    tracks = db.relationship('Track',
                             secondary='track_features',
                             back_populates='features')
Example #5
0
class Genre(db.Model):
    __tablename__ = 'genres'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100))
    playlists = db.relationship('Playlist', back_populates='genre')
    artists = db.relationship('Artist', back_populates='genre')
    tracks = db.relationship('Track', back_populates='genre')
Example #6
0
class Track(db.Model):
    __tablename__ = 'tracks'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100))
    spotify_id = db.Column(db.String(100))
    track_popularity = db.Column(db.Integer)
    featured_artist = db.Column(db.Boolean)
    top_track = db.Column(db.Boolean)
    features = db.relationship('Feature',
                               secondary='track_features',
                               back_populates='tracks')
    artist_id = db.Column(db.Integer, db.ForeignKey('artists.id'))
    artist = db.relationship('Artist', back_populates='tracks')
    album_id = db.Column(db.Integer, db.ForeignKey('albums.id'))
    album = db.relationship('Album', back_populates='tracks')
    playlists = db.relationship('Playlist',
                                secondary='playlist_tracks',
                                back_populates='tracks')
    genre_id = db.Column(db.Integer, db.ForeignKey('genres.id'))
    genre = db.relationship('Genre', back_populates='tracks')