def updateAvgRatings(): start_time = time.time() counter = 1 db = database_connector.DataBase() personids = db.get_all_person_id() print(personids) total = len(personids) for person, averageR in personids: if averageR is None: avgRating = db.get_averagerating_by_id(person) db.update_avg_rating(person,avgRating) percentage = (counter / total) * 100 _print_progress(round(percentage, 2), start_time) counter = counter + 1
def addCrewByName(self, name, role): db = DatabaseConnector.DataBase() nconst = db.get_person_id_by_name(name) avgrating = db.get_averagerating_by_id(nconst[0]) if nconst[0] is None: print("Actor not found!") return else: ordering = len(self.actors) + 1 if ordering > 10: print("Too many Actors in Movie " + self.title) else: actordata = [nconst[0], ordering, role, avgrating] self.actors.append(actor.Actor(actordata)) db.closeConnection()
def loadDataBase(): start_time = time.time() counter = 1 odd = True db = database_connector.DataBase() movies = [] print("Loading Database...") query = db.get_valid_movies() total = len(query) for line in query: newMovie = movie.Movie(line) newMovie.addActors(db.get_crew_of_movie(newMovie.id)) movies.append(newMovie) percentage = (counter / total) * 100 if (odd == True): _print_progress(round(percentage, 2), start_time) counter = counter + 1 odd = False else: odd = True counter = counter + 1 db.closeConnection() print("\nDatabase loaded.") return movies
def getName(self): db = DataBase.DataBase() person = db.get_person_by_id(self.nconst) db.closeConnection() return person[1]
def _personIdEncoder(self): db = database_connector.DataBase() nconsts = db.get_all_person_id() lb = preprocessing.LabelEncoder() lb.fit(nconsts) return lb