def __init__(self, file_name: str): movie_reader = MovieFileCSVReader(file_name) movie_reader.read_csv_file() self.__file_name = file_name self.dataset_of_movies = movie_reader.dataset_of_movies self.__dataset_of_actors = movie_reader.dataset_of_actors self.__dataset_of_directors = movie_reader.dataset_of_directors self.__dataset_of_genres = movie_reader.dataset_of_genres self._users = [] self._reviews = []
def populate(session_factory, data_path, filename): movie_file_reader = MovieFileCSVReader(filename) movie_file_reader.read_csv_file() movie_file_reader.read_csv_file_movies() # create a configured "Session" class Session = sessionmaker(bind=session_factory) # create a Session session = Session() # session = session_factory() # This takes all movies from the csv file (represented as domain model objects) and adds them to the # database. If the uniqueness of directors, actors, genres is correctly handled, and the relationships # are correctly set up in the ORM mapper, then all associations will be dealt with as well! for movie in movie_file_reader.dataset_of_movies: session.add(movie) session.commit()
def file_reader(): file_reader = MovieFileCSVReader( 'movie_web_app/adapters/Data1000Movies.csv') file_reader.read_csv_file() return file_reader