Skip to content

Commit

Permalink
fix: handle update of movie with genre as n/a
Browse files Browse the repository at this point in the history
  • Loading branch information
mochatek committed Nov 26, 2022
1 parent e75d590 commit d75af9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions services/DB.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ def init_db():
def insert_one(folder_name: str, data: dict):
conn = connect(DB_FILE)
cursor = conn.cursor()
cursor.execute('INSERT INTO movies(folder_name, genres, data) VALUES(?, ?, ?)', construct_values(folder_name, data))
folder_name, genres, data = construct_values(folder_name, data)
cursor.execute(
"""INSERT INTO movies (folder_name, genres, data) VALUES (?, ?, ?)
ON CONFLICT (folder_name) DO UPDATE SET genres=?, data=? where folder_name=?""",
(folder_name, genres, data, genres, data, folder_name))
conn.commit()
cursor.close()
conn.close()
Expand Down Expand Up @@ -50,7 +54,8 @@ def get_many(folder_names):
conn = connect(DB_FILE)
cursor = conn.cursor()
movies = cursor.execute(
"SELECT folder_name, genres FROM movies WHERE folder_name IN ({seq})".format(seq=','.join(['?']*len(folder_names))), tuple(folder_names)).fetchall()
"SELECT folder_name, genres FROM movies WHERE folder_name IN ({seq})".
format(seq=','.join(['?']*len(folder_names))), tuple(folder_names)).fetchall()
cursor.close()
conn.close()
return marshal_response(movies)
Expand Down
Binary file modified web/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d75af9e

Please sign in to comment.