def test_artist_track_relationship(self, memory_db): artist_1 = Artist(spotify_id='artist_spotify_id_1', artist_name='artist_name_1', followers=11) artist_2 = Artist(spotify_id='artist_spotify_id_2', artist_name='artist_name_2', followers=22) memory_db.session.add_all([artist_1, artist_2]) memory_db.session.commit() track_1 = Track(track_id='spotify_id_1', track_name='track_1', artist_id=1) track_2 = Track(track_id='spotify_id_2', track_name='track_2', artist_id=1) track_3 = Track(track_id='spotify_id_3', track_name='track_3', artist_id=2) memory_db.session.add_all([track_1, track_2, track_3]) memory_db.session.commit() assert track_1.artist == artist_1 assert track_2.artist == artist_1 assert track_3.artist == artist_2
def example_tracks(): t1 = Track( id=1, user_id=1, gpxfile_id=1, title="Track 01", time_start=datetime.utcnow(), time_end=datetime.utcnow() + timedelta(minutes=5), length2d=1000, length3d=1000, max_speed=20, avg_speed=10, total_uphill=50, total_downhill=50, moving_time=300, stopped_time=0, activity_mode=ActivityMode.BIKE.value, thumbnail=str(uuid4()), ) t2 = Track( id=2, user_id=1, gpxfile_id=1, title="Track 02", time_start=datetime.utcnow(), time_end=datetime.utcnow() + timedelta(minutes=5), length2d=1000, length3d=1000, max_speed=20, avg_speed=10, total_uphill=50, total_downhill=50, moving_time=300, stopped_time=0, activity_mode=ActivityMode.BIKE.value, thumbnail=str(uuid4()), ) t3 = Track( id=3, user_id=1, gpxfile_id=2, title="Track 03", time_start=datetime.utcnow(), time_end=datetime.utcnow() + timedelta(minutes=5), length2d=1000, length3d=1000, max_speed=20, avg_speed=10, total_uphill=50, total_downhill=50, moving_time=300, stopped_time=0, activity_mode=ActivityMode.HIKING.value, thumbnail=str(uuid4()), ) db.session.add_all([t1, t2, t3]) db.session.commit()
def recommended_track(spotify): form = SongSearchForm() if form.validate_on_submit(): track_ids = [form.song1_id.data, form.song2_id.data] audio_features = AudioFeatures(spotify.audio_features(tracks=track_ids)) recommendations = spotify.recommendations( limit=1, seed_tracks=track_ids, target_danceability=audio_features.mean('danceability'), target_acousticness=audio_features.mean('acousticness'), target_energy=audio_features.mean('energy'), target_instrumentalness=audio_features.mean('instrumentalness'), target_key=round(audio_features.mean('key')), target_liveness=audio_features.mean('liveness'), target_loudness=audio_features.mean('loudness'), # target_mode=audio_features.mean('mode'), # target_popularity=round(audio_features.mean('popularity')), target_speechiness=audio_features.mean('speechiness'), target_tempo=audio_features.mean('tempo'), target_time_signature=round(audio_features.mean('time_signature')), target_valence=audio_features.mean('valence') ) track = Track(recommendations['tracks'][0]) user_id = spotify.current_user()['id'] spotify.user_playlist_add_tracks(user_id, form.playlist_id.data, [track.id()], form.position.data) return redirect(url_for('playlist', playlist_id=form.playlist_id.data)) else: return redirect(request.referrer or url_for('index'))
def import_track(gpxfile, gpx_track, gpxfile_track_id): start_time, end_time = gpx_track.get_time_bounds() moving_data = gpx_track.get_moving_data() uphill, downhill = gpx_track.get_uphill_downhill() avg_speed = (speed_to_kph(moving_data.moving_distance / moving_data.moving_time) if moving_data.moving_time > 0.0 else 0.0) track = Track( owner=gpxfile.owner, file=gpxfile, gpxfile_track_id=gpxfile_track_id, title=gpx_track.name if gpx_track.name else gpxfile.filename, time_start=start_time, time_end=end_time, length2d=gpx_track.length_2d(), length3d=gpx_track.length_3d(), max_speed=speed_to_kph(moving_data.max_speed), avg_speed=avg_speed, moving_time=moving_data.moving_time, stopped_time=moving_data.stopped_time, total_uphill=uphill, total_downhill=downhill, activity_mode=default_activity_mode_from_average_speed(avg_speed), thumbnail=str(uuid4()), ) db.session.add(track) return track
def matching_track(phrase): # phrase may not be in the db at all, or it may be a Track-less Phrase p = Phrase.query.filter_by(name=phrase).first() if not p: p = Phrase(name=phrase) db.session.add(p) db.session.commit() form_str = "\'" + phrase + "\'" chunk_max = 10 for chunk in range(chunk_max): results = sp.search(q=form_str, type='track', limit=50, offset=chunk * 50) results = results['tracks']['items'] for track in results: if phrase == track['name'].lower(): t = Track(name=track['name'], artists=track['artists'][0]['name'], album=track['album']['name'], spot_id=track['id'], image_url=track['album']['images'][0]['url'], phrase=p) db.session.add(t) db.session.commit() return t
def add_update_db(url): track_id = url[-22:] track_uri = str("spotify:track:") + track_id search = sp.track(track_uri) track_name = search['name'] track_popularity = search['popularity'] duration = search['duration_ms'] explicit = search['explicit'] release_date = search['album']['release_date'] year = release_date[:3] artist_idx = search['artists'][0]['id'] search = sp.artist(artist_idx) genres = json.dumps(search['genres']) artist_name = search['name'] artist_uri = search['uri'] artist_popularity = search['popularity'] search = sp.audio_features(track_id) danceability = search[0]['danceability'] energy = search[0]['energy'] key = search[0]['key'] loudness = search[0]['loudness'] mode = search[0]['mode'] speechiness = search[0]['speechiness'] acousticness = search[0]['acousticness'] instrumentalness = search[0]['instrumentalness'] liveness = search[0]['liveness'] valence = search[0]['valence'] tempo = search[0]['tempo'] x = Artist(id=artist_idx, name=artist_name, uri=artist_uri, genres=genres, popularity=artist_popularity) y = Track(id=track_id, name=track_name, uri=track_uri, popularity=track_popularity, duration=duration, explicit=explicit, release_date=release_date, year=year, artist_id=artist_idx, danceability=danceability, energy=energy, key=key, loudness=loudness, mode=mode, speechiness=speechiness, acousticness=acousticness, instrumentalness=instrumentalness, liveness=liveness, valence=valence, tempo=tempo) sess.merge(x) sess.merge(y) sess.commit()
def transform(self, json): return Track(author=json.get(self.AUTHOR, [''])[0], lyric=json.get(self.LYRIC, [''])[0], number=int(json[self.NUMBER][0]), ref=json.get(self.REF, [None])[0], title=json[self.TITLE][0], vol=int(json.get(self.VOL, [0])[0]) if json.get( self.VOL, [0])[0] is not None else 0)
def test_delete_track_automatically_removes_thumbnail_file(app, example_users): track = Track(id=1, thumbnail=str(uuid4())) db.session.add(track) db.session.commit() create_empty_file(track.thumbnail_path()) assert os.path.isfile(track.thumbnail_path()) db.session.delete(track) db.session.commit() assert not os.path.isfile(track.thumbnail_path())
def post(self): data = request.get_json(force=True) if not data: return {'message': 'No input data provided'}, 400 track = Track(user_id=g.user.id, number=data['number'], title=data['title']) db.session.add(track) db.session.commit() return {'data': as_json(track)}, 200
def add_track(args): """Seeds an existing database with additional songs. Args: args: Argparse args - should include args.title, args.artist, args.album Returns:None """ track = Track(artist=args.artist, album=args.album, title=args.title) db.session.add(track) db.session.commit() logger.info("%s by %s from album, %s, added to database", args.title, args.artist, args.album)
def uploadTrack(artistId, projectId): ''' Adds new track to a project [X] ''' user = current_user if not user.superUser: return {"Errors": "User Not Authorized to create a track"} form = TrackForm() project = Project.query.get(projectId).to_dict() form['csrf_token'].data = request.cookies['csrf_token'] if form.validate_on_submit(): data = Track(name=form.data['name'], projectId=project['id']) db.session.add(data) db.session.commit() return data.to_dict()
def create_db(args): """Creates a database with the data model given by obj:`apps.models.Track` Args: args: Argparse args - should include args.title, args.artist, args.album Returns: None """ db.create_all() track = Track(artist=args.artist, album=args.album, title=args.title) db.session.add(track) db.session.commit() logger.info("Database created with song added: %s by %s from album, %s ", args.title, args.artist, args.album)
def tracks(album_id=None): form = CreateTrackForm() # Get MediaType information and populate the form form.media_type.choices = [ (str(media_type.media_type_id), media_type.name) for media_type in MediaType.query.order_by(MediaType.media_type_id) ] # Get Genre information and populate the form form.genre.choices = [(str(genre.genre_id), genre.name) for genre in Genre.query.order_by(Genre.genre_id)] # Get the album album = (db.session.query(Album).filter( Album.album_id == album_id).one_or_none()) form.album.data = album.title artist = album.artist form.artist.data = artist.name # Is the form valid? if form.validate_on_submit(): # Create new Track track = Track( name=form.name.data, media_type_id=form.media_type.data, genre_id=form.genre.data, composer=form.composer.data, milliseconds=form.milliseconds.data, bytes=form.bytes.data, unit_price=form.unit_price.data, ) album.tracks.append(track) db.session.add(album) db.session.commit() # Get the tracks tracks = db.session.query(Track).filter(Track.album_id == album_id).all() return render_template("tracks.html", artist=artist, album=album, tracks=tracks, form=form)
def add_entry(): """View that process a POST with new song input :return: redirect to index page """ try: track1 = Track(artist=request.form['artist'], album=request.form['album'], title=request.form['title']) db.session.add(track1) db.session.commit() logger.info("New song added: %s by %s", request.form['title'], request.form['artist']) return redirect(url_for('index')) except: logger.warning("Not able to display tracks, error page returned") return render_template('error.html')
def upload(): form = UploadForm() if form.validate_on_submit(): f = form.upload.data if not allowed_audio_file(f.filename): flash("Invalid file type.") return redirect(url_for('upload')) filename = secure_filename(f.filename) f.save(os.path.join(app.config['UPLOAD_FOLDER'], 'audio', filename)) track = Track(title=form.title.data, description=form.description.data, filename=filename, artist=current_user) db.session.add(track) db.session.commit() flash("Upload Successful.") return redirect(url_for('music', username=current_user.username)) return render_template('upload.html', title='Upload Music', form=form)
def load_records(self): """ Load Artist records into Database. """ triage = [] assert len(spotify.artist_data) == len(spotify.track_data) for artist, tracks in zip(spotify.artist_data, spotify.track_data): try: artist_exists = (db.session.query(Artist.id).filter_by( spotify_id=artist['spotify_id']).scalar() is not None) # pdb.set_trace() if not artist_exists: artist_rec = Artist(**artist) db.session.add(artist_rec) for track in tracks: track_exists = (db.session.query(Track.id).filter_by( track_id=track['track_id']).scalar() is not None) if not track_exists: track_rec = Track(**track, artist=artist_rec) db.session.add(track_rec) except Exception as e: # log exception # add to triage table # Fails with UnboundLocalError triage.append({'artist': artist, 'track': track, 'Error': e}) raise db.session.commit() # pdb.set_trace() return triage
artist_track = str(artist) + ' - ' + str(track) # Add uniques if artist not in artists: artists[artist] = len(artists) aobj = Artist( artists[artist], artist ) db.session.add(aobj) if artist_track not in artist_tracks: artist_tracks[artist_track] = len(artist_tracks) tobj = Track( artist_tracks[artist_track], artists[artist], track ) db.session.add(tobj) if collection not in collections: collections[collection] = len(collections) cobj = Collection( collections[collection], collection ) db.session.add(cobj) if cdg_mp3_pair not in cdg_mp3_pairs: cdg_mp3_pairs[cdg_mp3_pair] = len(cdg_mp3_pairs) cmobj = CdgMp3Pair(
def upload_track(artist_name): artist = Artist.objects(name=artist_name).first_or_404() if current_user not in artist.members: flash('You are not authorized to upload tracks for {}'.format( artist.name)) return redirect(url_for('main.artist', artist_name=artist.name)) form = UploadTrackForm() form.genre.choices = [(genre.id, genre.name) for genre in Genre.objects.order_by('name')] if form.validate_on_submit(): file = form.track.data if not allowed_file(file.filename): flash('Only music files are allowed') return render_template('upload_track.html', form=form, artist=artist, title='Upload Track') file.filename = secure_filename(file.filename) s3_filepath, cloudfront_filepath = upload_file_to_s3( file, current_app.config['S3_BUCKET']) track_exists = Track.objects(s3_filepath=s3_filepath, cloudfront_filepath=cloudfront_filepath ).first() is not None # 1 if track exists if s3_filepath is not None and cloudfront_filepath is not None and not track_exists: new_track = Track(track_name=form.track_name.data, artist=artist, duration=0, genre=[ Genre.objects(id=genre).first() for genre in form.genre.data ], s3_filepath=s3_filepath, cloudfront_filepath=cloudfront_filepath) new_track.save(cascade=True) # Saves the track in the mongoDB # filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], file.filename) # new_track = Track(track_name=form.track_name.data, artist=artist, duration=0, # genre=[Genre.objects(id=genre).first() for genre in form.genre.data], filepath=filepath) # new_track.save(cascade=True) # Saves the track in the mongoDB # file.save(filepath) artist.tracks.append(new_track) artist.save(cascade=True) # Save artist with new track flash('Track successfully uploaded') return redirect(url_for('main.artist', artist_name=artist_name)) else: if track_exists: flash('Track already exists!') return render_template('upload_track.html', form=form, artist=artist, title='Upload Track') else: flash('Error uploading file') return render_template('upload_track.html', form=form, artist=artist, title='Upload Track') return render_template('upload_track.html', form=form, artist=artist, title='Upload Track')
def test_can_delete_track_thumbnail(app): track = Track(thumbnail=str(uuid4())) create_empty_file(track.thumbnail_path()) assert os.path.isfile(track.thumbnail_path()) track.delete_thumbnail_file() assert not os.path.isfile(track.thumbnail_path())
def test_track_thumbnail_path_returns_correct_filename(app): app.config["THUMBNAILS_FOLDER"] = "thumbnails" uuid = str(uuid4()) track = Track(thumbnail=uuid) assert track.thumbnail_path() == os.path.join("thumbnails", f"{uuid}.png")
def test_track_default_activity_mode_is_bike(app): track = Track(user_id=1, gpxfile_id=1, avg_speed=10.0) db.session.add(track) db.session.commit() assert track.activity_mode == ActivityMode.BIKE
def test_can_create_uni(db: Session) -> None: uni = University(name_translations={"en": "Test Uni", "he": "אוני בדיקה"}) terms = [ Term(id=1, name_translations={"en": "Semester 1"}), Term(id=2, name_translations={"en": "Semester 2"}), Term(id=3, name_translations={"en": "Semester 1/2"}), ] fac = Faculty( university=uni, id="facCSE", name_translations={ "en": "Computer Science and Engineering", "he": 'ביה"ס להנדסה ולמדעי המחשב', }, ) dep = Department( faculty=fac, id="521", name_translations={"en": "Computer Science", "he": "מדעי המחשב"}, ) dep2 = Department( faculty=fac, id="583", name_translations={ "en": "Electrical & Computer Engineering", "he": "הנדסת חשמל ומחשבים", }, ) tracks = [ Track( university=uni, id="23010", degree=DegreeType.Bachelors, name_translations={"he": 'מדמ"ח חד חוגי מורחב'}, departments=[dep], ), Track( university=uni, id="125860", degree=DegreeType.Bachelors, name_translations={"he": "הנדסת חשמל ומחשבים עם התחמות בהנדסת מחשבים"}, departments=[dep2], ), ] course_names = [ "Infi1", "Infi2", "LinAlg1", "LinAlg2", "Probability", "IML", "Logic1", "LogicCS", "Intro2CS" ] courses = { name: Course( university=uni, id=f"C_{name.upper()}", name_translations={ "en": name }, term=terms[0], course_credits=1337 ) for name in course_names } db.add_all(courses.values()) infi1 = singleton_course_node(courses["Infi1"]) infi2 = singleton_course_node(courses["Infi2"]) infi1.children.append(infi2) lin1 = singleton_course_node(courses["LinAlg1"]) lin2 = singleton_course_node(courses["LinAlg2"]) lin1.children.append(lin2) prob = singleton_course_node(courses["Probability"]) prob.parents.append(lin2) iml = singleton_course_node(courses["IML"]) logic1 = singleton_course_node(courses["Logic1"]) logic_cs = singleton_course_node(courses["LogicCS"]) intro = singleton_course_node(courses["Intro2CS"]) logic_cs.parents.append(intro) iml.parents.extend([prob, infi2, lin2]) or_node = ORNode() or_node.university = uni or_node.children.extend([logic1, logic_cs]) cs_extended_root = DAGRootNode() cs_extended_root.track = tracks[0] cs_extended_root.university = uni cs_extended_root.children.extend([ infi1, lin1, or_node, intro ]) db.add(cs_extended_root) db.commit()
def track_add(id): if id == 'all': Track.index_all() else: track = Track(id=id).index() return redirect(request.referrer or url_for('index'))
def refresh_data(sched_info_fname, convention_info_fname=None): # Keep track of the number of errors and warnings. num_errors = 0 num_warnings = 0 # Delete records from tables of interest. events = Event.query.all() for event in events: event.rooms = [] event.presenters = [] event.timeslots = [] db.session.commit() DataLoadError.query.delete() Convention.query.delete() Timeslot.query.delete() Track.query.delete() Event.query.delete() Presenter.query.delete() Room.query.delete() RoomGroup.query.delete() # Define the convention. if not convention_info_fname: script_dir = os.path.dirname(__file__) convention_info_fname = os.path.join(script_dir, CONVENTION_INFO_FNAME) convention = Convention() with open(convention_info_fname, 'rb') as csvfile: csvreader = csv.reader(csvfile, delimiter=',', quotechar='"') first_row = True for row in csvreader: if first_row: first_row = False else: convention.name = row[0] convention.description = row[1] convention.date_format = row[5] convention.datetime_format = row[6] convention.start_dt = datetime.datetime.strptime( row[2], convention.datetime_format) convention.end_dt = datetime.datetime.strptime( row[3], convention.datetime_format) convention.timeslot_duration = datetime.timedelta( 0, int(row[4]) * 60) # Minutes converted to seconds. convention.url = row[7] convention.active = True # There is only one row of convention data. break db.session.add(convention) db.session.commit() # Commit the data to the database. db.session.commit() # Create timeslots. timeslot_count = int( (convention.end_dt - convention.start_dt).total_seconds() / convention.timeslot_duration.total_seconds()) for n in range(timeslot_count): timeslot = Timeslot(n) timeslot.active = True db.session.add(timeslot) # Commit the data to the database. db.session.commit() # Add tracks. # The track name and the email address for each CREM track. track_infos = ( ('Literature', '*****@*****.**'), ('Tech', '*****@*****.**'), ('After Dark', '*****@*****.**'), ('Action Adventure', '*****@*****.**'), ('Costuming', '*****@*****.**'), ('Comics', '*****@*****.**'), ('Gaming', '*****@*****.**'), ('DIY', '*****@*****.**'), ('Food', '*****@*****.**'), ('Science', '*****@*****.**'), ('Media', '*****@*****.**'), ('Mayhem', '*****@*****.**'), ('Anime', '*****@*****.**'), ('Penguicon', '*****@*****.**'), ('Life', '*****@*****.**'), ) # Create tracks and save database objects in dictionary for later reference. tracks = {} for track_info in track_infos: track = Track(track_info[0], track_info[1]) tracks[track_info[0]] = track db.session.add(track) # Commit the data to the database. db.session.commit() # Add room groups. room_group_names = ( 'Algonquin', 'Charlevoix', 'Lobby', ) for room_group_name in room_group_names: room_group = RoomGroup(room_group_name) db.session.add(room_group) # Commit the data to the database. db.session.commit() # Add rooms. # For each room, the name, square feet, capacity and room group it belongs to. room_infos = ( ('Algonquin A', 1207, 100, 'Algonquin'), ('Algonquin B', 1207, 100, 'Algonquin'), ('Algonquin C', 1207, 100, 'Algonquin'), ('Algonquin D', 1207, 100, 'Algonquin'), ('Algonquin Foyer', 3000, 450, None), ('Charlevoix A', 756, 64, 'Charlevoix'), ('Charlevoix B', 756, 64, 'Charlevoix'), ('Charlevoix C', 756, 64, 'Charlevoix'), ('Portage Auditorium', 1439, 68, None), ('Windover', 1475, 40, None), ('TC Linguinis', 1930, 40, None), ('Baldwin Board Room', 431, 12, None), ('Board of Directors', 511, 15, None), ('Board of Governors', 391, 5, None), ('Board of Regents', 439, 15, None), ('Board of Trustees', 534, 40, None), ('Hamlin', 360, 25, None), ('Montcalm', 665, 50, None), ('Nicolet', 667, 50, None), ('Game Table A', 20, 10, 'Lobby'), ('Game Table B', 20, 10, 'Lobby'), ('Game Table C', 20, 10, 'Lobby'), ('Game Table D', 20, 10, 'Lobby'), ) # Create rooms and save database objects in dictionary for later reference. rooms = {} for room_info in room_infos: room = Room() room.room_name = room_info[0] room.room_sq_ft = room_info[1] room.room_capacity = room_info[2] if room_info[3]: room.room_group = db.session.query(RoomGroup).\ filter(RoomGroup.room_group_name == room_info[3]).first() rooms[room.room_name] = room db.session.add(room) # Commit the data to the database. db.session.commit() # Keep track of presenters. presenters = {} # Read events from file. with open(sched_info_fname, 'rb') as csvfile: csvreader = csv.reader(csvfile, delimiter=',', quotechar='"') first_row = True for row in csvreader: if first_row: first_row = False continue if len(row) < 11: load_error = DataLoadError() load_error.error_level = 'Error' load_error.destination_table = 'event' load_error.line_num = csvreader.line_num load_error.error_msg = 'Not enough columns in row %d' % csvreader.line_num load_error.error_dt = datetime.datetime.now() db.session.add(load_error) num_errors += 1 continue trackname = row[5].split(',')[0].strip() if trackname not in tracks: # There is no corresponding track, so add it. email = '-'.join( trackname.lower().split()) + '*****@*****.**' track = Track(trackname, email) tracks[trackname] = track db.session.add(track) load_error = DataLoadError() load_error.error_level = 'Warning' load_error.destination_table = 'event' load_error.line_num = csvreader.line_num load_error.error_msg = '%s is not a defined track; adding it' % trackname load_error.error_dt = datetime.datetime.now() db.session.add(load_error) num_errors += 1 continue event = Event() event.title = row[6] event.description = row[8] event.track = tracks[trackname] # Add timeslots and duration. try: timeslots = get_timeslots(row[0], row[1], row[9], convention, Timeslot) event.timeslots = timeslots event.duration = len(timeslots) except Exception as e: load_error = DataLoadError() load_error.error_level = 'Error' load_error.destination_table = 'event' load_error.line_num = csvreader.line_num load_error.error_msg = str(e) load_error.error_dt = datetime.datetime.now() db.session.add(load_error) num_errors += 1 continue event.facilityRequest = row[10] event.convention = convention # Add room to the event. if row[4].strip(): if row[4] not in rooms: # This is not a predefined room, so add it. load_error = DataLoadError() load_error.error_level = 'Warning' load_error.destination_table = 'event' load_error.line_num = csvreader.line_num load_error.error_msg = '%s is not a pre-defined room; adding this room' % row[ 4] load_error.error_dt = datetime.datetime.now() num_warnings += 1 db.session.add(load_error) room = Room() room.room_name = row[4] room.room_sq_ft = 0 room.room_capacity = 0 rooms[row[4]] = room db.session.add(room) else: room = rooms[row[4]] event.rooms.append(room) # Add presenters. if row[7].strip(): presenter_names = row[7].split(',') presenter_names = [s.strip() for s in presenter_names] for presenter_name in presenter_names: if presenter_name in presenters: presenter = presenters[presenter_name] else: last_name = presenter_name.split(' ')[-1].strip() first_name = ' '.join( presenter_name.split(' ')[0:-1]).strip() presenter = Presenter(first_name, last_name) presenters[presenter_name] = presenter db.session.add(presenter) event.presenters.append(presenter) db.session.add(event) # Commit the data to the database. db.session.commit() # Return the number of errors and warnings. return num_errors, num_warnings
def _make_db_track(sp_track): lib_track = Track() _update_lib_track(lib_track, sp_track) db.session.add(lib_track) _add_item_artists(lib_track, sp_track['artists']) return lib_track
def seed_tracks(): data = [ Track(name='The Night Resumes', projectId=1), Track(name='Noblesville, 1905', projectId=1), Track(name='Blackwater', projectId=1), Track(name='Untitled (The Dead Sea Scrolls)', projectId=1), Track(name='Constellations', projectId=1), Track(name='An Conair', projectId=1), Track(name='Anyone Seen The Light?', projectId=1), Track(name='Stranger(On The Docks)', projectId=1), Track(name='The Backward Look', projectId=1), Track(name='Goin up to Country', projectId=2), Track(name='Snow Day', projectId=3), Track(name='Language', projectId=3), Track(name='Color', projectId=3), Track(name='Skin & Bones', projectId=3), Track(name='KGNU', projectId=3), ] for track in data: db.session.add(track) db.session.commit()