scan_vids: Fix syntax errors in SQL queries, handle case video is missing and update doesn't return a row
This commit is contained in:
+7
-1
@@ -47,6 +47,8 @@ def video_exists(con: psycopg.Connection, file_path: str) -> bool:
|
||||
[file_path],
|
||||
)
|
||||
row = stmt.fetchone()
|
||||
if not row:
|
||||
return False
|
||||
return row["exists"]
|
||||
|
||||
|
||||
@@ -61,7 +63,11 @@ def save_video(
|
||||
ffprobe: dict,
|
||||
hash_partial: str,
|
||||
):
|
||||
sql = """INSERT INTO videos(category, file_path, ffprobe, hash_partial) VALUES (%s, %s, %s, %s) ON CONFLICT(file_path) SET last_seen_at = NOW();"""
|
||||
sql = """
|
||||
INSERT INTO videos(category, file_path, ffprobe, hash_partial)
|
||||
VALUES (%s, %s, %s, %s)
|
||||
ON CONFLICT(file_path) DO UPDATE SET
|
||||
last_seen_at = NOW();"""
|
||||
con.execute(
|
||||
sql,
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user