def _insert_country_vectors(self): session.query(CountryVector).delete() for country_id, country_vector in self.implicit_mf.country_vectors.vectors.iterrows( ): session.add( CountryVector(country_id=int(country_id), **country_vector)) session.commit()
def insert_countries(): for country_name in countries.keys(): country = Country(id=countries[country_name]['id'], name=country_name, value=country_name) session.add(country) session.commit()
def insert_operators(): for operator_id in OPERATORS.keys(): operator = Operator(id=operator_id, name=OPERATORS[operator_id]['name'], value=OPERATORS[operator_id]['value']) session.add(operator) session.commit()
def _setUp_songs(self): for song_id, song in DUMMY_SONGS.iterrows(): session.add( Song(id=int(song_id), title=song['Track Name'], artist=song['Artist'], url=song['URL'])) session.commit()
def insert_operators(): for operator_id in OPERATORS.keys(): operator = Operator( id=operator_id, name=OPERATORS[operator_id]['name'], value=OPERATORS[operator_id]['value'] ) session.add(operator) session.commit()
def insert_countries(): for country_name in countries.keys(): country = Country( id=countries[country_name]['id'], name=country_name, value=country_name ) session.add(country) session.commit()
def run(self, date): for country_name in countries.keys(): top_songs_generator = TopSongsGenerator(country_name=country_name, date=date) if not top_songs_generator.daily_chart.dataframe.empty: for top_song in top_songs_generator: if not self._top_song_exists(top_song): session.add(top_song) session.commit()
def _insert_song_vectors(self): session.query(SongVector).delete() for song_id, song_vector in self.implicit_mf.song_vectors.vectors.iterrows( ): session.add(SongVector(song_id=int(song_id), **song_vector)) session.commit()
def tearDown(self): session.query(CountryVector).delete() session.query(SongVector).delete() session.query(Song).delete() session.commit()
def insert_top_songs(): for country_name in countries.keys(): for top_song in TopSongsGenerator(country_name): session.add(top_song) session.commit()
def _insert_song_vectors(self): session.query(SongVector).delete() for song_id, song_vector in self.implicit_mf.song_vectors.vectors.iterrows(): session.add(SongVector(song_id=int(song_id), **song_vector)) session.commit()
def _insert_country_vectors(self): session.query(CountryVector).delete() for country_id, country_vector in self.implicit_mf.country_vectors.vectors.iterrows(): session.add(CountryVector(country_id=int(country_id), **country_vector)) session.commit()