def start(self):
        """Starts the concurrent threads to add rows to the database's tables.
        """
        for i in range(1, 8):
            thread = FilmThread("http://swapi.co/api/films/" + str(i))
            FilmThread.thread_list += [thread]
            thread.start()

        for thread in FilmThread.thread_list:
            thread.join()

        for film in FilmModel.select().order_by(FilmModel.release_date):
            FilmThread.ordered_arr.append(film)

        CharactersThread.id_list = set(CharactersThread.id_list)

        for i in CharactersThread.id_list:
            thread = CharactersThread("http://swapi.co/api/people/" + str(i))
            CharactersThread.thread_list += [thread]
            thread.start()

        for thread in CharactersThread.thread_list:
            thread.join()

        PlanetThread.id_list = set(PlanetThread.id_list)

        for i in PlanetThread.id_list:
            thread = PlanetThread("http://swapi.co/api/planets/" + str(i))
            PlanetThread.thread_list += [thread]
            thread.start()

        for thread in PlanetThread.thread_list:
            thread.join()

        return
    def start(self):
        '''Starts the concurrent threads to add rows to the database's tables.
        '''
        for i in range(1, 8):
            thread = FilmThread("http://swapi.co/api/films/" + str(i))
            FilmThread.thread_list += [thread]
            thread.start()

        for thread in FilmThread.thread_list:
            thread.join()

        for film in FilmModel.select().order_by(FilmModel.release_date):
            FilmThread.ordered_arr.append(film)

        CharactersThread.id_list = set(CharactersThread.id_list)

        for i in CharactersThread.id_list:
            thread = CharactersThread("http://swapi.co/api/people/" + str(i))
            CharactersThread.thread_list += [thread]
            thread.start()

        for thread in CharactersThread.thread_list:
            thread.join()

        PlanetThread.id_list = set(PlanetThread.id_list)

        for i in PlanetThread.id_list:
            thread = PlanetThread("http://swapi.co/api/planets/" + str(i))
            PlanetThread.thread_list += [thread]
            thread.start()

        for thread in PlanetThread.thread_list:
            thread.join()

        return
    def run(self):
        '''Defines the threads activity. Makes a row in the FilmModel table
        with the corresponding data pulled from a request to the Star Wars API.
        '''
        data = requests.get(self.__url)
        obj = json.loads(data.text)
        FilmModel.create(title=str(obj.get("title")),
                         release_date=str(obj.get("release_date")),
                         episode_id=str(obj.get("episode_id")))

        for c in obj.get("characters"):
            c = c.split("/")
            character_id = c[-2]
            CharactersThread.id_list.append(str(character_id))

        for c in obj.get("planets"):
            c = c.split("/")
            planet_id = c[-2]
            PlanetThread.id_list.append(str(planet_id))
    def run(self):
        """Defines the threads activity. Makes a row in the FilmModel table
        with the corresponding data pulled from a request to the Star Wars API.
        """
        data = requests.get(self.__url)
        obj = json.loads(data.text)
        FilmModel.create(
            title=str(obj.get("title")),
            release_date=str(obj.get("release_date")),
            episode_id=str(obj.get("episode_id")),
        )

        for c in obj.get("characters"):
            c = c.split("/")
            character_id = c[-2]
            CharactersThread.id_list.append(str(character_id))

        for c in obj.get("planets"):
            c = c.split("/")
            planet_id = c[-2]
            PlanetThread.id_list.append(str(planet_id))