|
|
|
@ -514,9 +514,13 @@ def storeTMDBQueryResults(query_obj, result_list): |
|
|
|
|
|
|
|
|
|
|
|
# NOTE: check stored details before trying to add to local db to avoid unique key |
|
|
|
# NOTE: check stored details before trying to add to local db to avoid unique key |
|
|
|
# constraint error |
|
|
|
# constraint error |
|
|
|
cur.execute(f'SELECT COUNT(*) FROM query_details WHERE {id_column}=?', (id_val, )) |
|
|
|
cur.execute(f'SELECT * FROM query_details WHERE {id_column}=?', (id_val, )) |
|
|
|
count = cur.fetchone()[0] |
|
|
|
match = cur.fetchone() |
|
|
|
if count > 0: |
|
|
|
if match is not None: |
|
|
|
|
|
|
|
cur.execute(f'INSERT INTO query_mapping(query_id, detail_id)' |
|
|
|
|
|
|
|
+ ' VALUES (?,?)', (query_id, match['detail_id']) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
current_app.logger.debug( |
|
|
|
current_app.logger.debug( |
|
|
|
f'skipping result that is already saved. {id_column}: {id_val}, title: {r.title}' |
|
|
|
f'skipping result that is already saved. {id_column}: {id_val}, title: {r.title}' |
|
|
|
) |
|
|
|
) |
|
|
|
@ -535,7 +539,7 @@ def storeTMDBQueryResults(query_obj, result_list): |
|
|
|
r.detail_id = cur.lastrowid |
|
|
|
r.detail_id = cur.lastrowid |
|
|
|
|
|
|
|
|
|
|
|
cur.execute(f'INSERT INTO query_mapping(query_id, detail_id)' |
|
|
|
cur.execute(f'INSERT INTO query_mapping(query_id, detail_id)' |
|
|
|
+ ' VALUES (?,?)', (query_id, cur.lastrowid) |
|
|
|
+ ' VALUES (?,?)', (query_id, r.detail_id) |
|
|
|
) |
|
|
|
) |
|
|
|
except DatabaseError as e: |
|
|
|
except DatabaseError as e: |
|
|
|
query_obj.errors.append(f'database error \'{e}\'') |
|
|
|
query_obj.errors.append(f'database error \'{e}\'') |
|
|
|
|