From 4d02fde9aa71a0aedc90c1be7adde2a9c1bc1bd6 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Wed, 7 Sep 2022 02:10:14 +0300 Subject: [PATCH] Correct fetching IMDB database --- src/imdb_datasets_worker.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/imdb_datasets_worker.py b/src/imdb_datasets_worker.py index ebf0ab3..b380c1f 100644 --- a/src/imdb_datasets_worker.py +++ b/src/imdb_datasets_worker.py @@ -84,20 +84,14 @@ def convert_datasets_to_db(): def get_title_by_id(films_ids=list): - tt_list = [] - for i in films_ids: - tt_film = c.execute("SELECT * FROM titles WHERE tt_id = (?)", (i,)).fetchone() - tt_list.append(tt_film) - return tt_list + tt_list = c.executemany("SELECT * FROM titles WHERE tt_id = (?)", films_ids).fetchall() + if tt_list != []: + return tt_list def get_title_by_names_and_year(film_names=list): - tt_list = [] - for i in film_names: - tt_film = c.execute('''SELECT * FROM titles + tt_list = c.executemany('''SELECT * FROM titles WHERE (original_name = (?) OR ru_name = (?)) - AND year = (?)''', i).fetchone() - if tt_film: - tt_list.append(tt_film) + AND year = (?)''', film_names).fetchall() if tt_list != []: return tt_list