def root(): # if database_exists( engine.url) == False: # """if specified db doesn't exist, create and run function to populate""" DB.drop_all() DB.create_all() fillSongDB() # < Alternative methods to get track id? > (depends on backend, who has been MIA since Tuesday..) # lines = request.values[ 'track_id'] # lines = request.args.get( 'seed', # default= '5xTtaWoae3wi06K5WfVUUH', # Haters gonna hate, hate, hate, hate, hate # type= 'str') # """ get input from front-end/json and save it to User table in db """ # lines = request.get_json( force= True) # for line in lines: # User.track_id = lines[ 'track_id'] # assert isinstance( User.track_id, str) # DB.session.add( User.track_id) # DB.commit() export = suggestSong( parseInput()) return APP.response_class( response= json.dumps( export), status= 200, mimetype= 'application/json' )
def refresh(): """Pull fresh data from Open AQ and replace existing data.""" DB.drop_all() DB.create_all() # TODO Get data from OpenAQ, make Record objects with it, and add to db aq_data.add_aq_to_db() DB.session.commit() return 'Data refreshed!'
def setUp(self): DB.drop_all() DB.create_all() collect = Collection('1', 'National Museum of Art', 'http://www.nga.gov', 'North America', 'Institution') DB.session.add(collect) DB.session.commit()
def setUp(self): DB.drop_all() DB.create_all() artwork = Artwork( '1', 'Statue of David', 'statue', 'Statue', '1000', 'http://a5.files.biography.com/image/upload/c_fit,cs_srgb,dpr_1.0,h_1200,q_80,w_1200/MTE5NDg0MDU1MTYxNzY3NDM5.jpg' ) DB.session.add(artwork) DB.session.commit()
def setUp(self): DB.drop_all() DB.create_all() style = Style( '1', 'Pop', 'cool', 'http://a5.files.biography.com/image/upload/c_fit,cs_srgb,dpr_1.0,h_1200,q_80,w_1200/MTE5NDg0MDU1MTYxNzY3NDM5.jpg' ) DB.session.add(style) DB.session.commit()
def setUp(self): DB.drop_all() DB.create_all() artist1 = Artist( '1', 'Andy Warhol', '1900', 'Male', 'American', 'http://a5.files.biography.com/image/upload/c_fit,cs_srgb,dpr_1.0,h_1200,q_80,w_1200/MTE5NDg0MDU1MTYxNzY3NDM5.jpg' ) DB.session.add(artist1) DB.session.commit()
def reset(): DB.drop_all() DB.create_all() return render_template('base.html', title='Reset Database')
def tearDown(self): """ Test deletion """ DB.session.remove() DB.drop_all()