@@ -62,8 +62,7 @@ def db_create_images_table() -> None:
6262 cursor = conn .cursor ()
6363
6464 # Create new images table with merged fields including Memories feature columns
65- cursor .execute (
66- """
65+ cursor .execute ("""
6766 CREATE TABLE IF NOT EXISTS images (
6867 id TEXT PRIMARY KEY,
6968 path VARCHAR UNIQUE,
@@ -77,8 +76,7 @@ def db_create_images_table() -> None:
7776 captured_at DATETIME,
7877 FOREIGN KEY (folder_id) REFERENCES folders(folder_id) ON DELETE CASCADE
7978 )
80- """
81- )
79+ """ )
8280
8381 # Create indexes for Memories feature queries
8482 cursor .execute ("CREATE INDEX IF NOT EXISTS ix_images_latitude ON images(latitude)" )
@@ -93,17 +91,15 @@ def db_create_images_table() -> None:
9391 )
9492
9593 # Create new image_classes junction table
96- cursor .execute (
97- """
94+ cursor .execute ("""
9895 CREATE TABLE IF NOT EXISTS image_classes (
9996 image_id TEXT,
10097 class_id INTEGER,
10198 PRIMARY KEY (image_id, class_id),
10299 FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
103100 FOREIGN KEY (class_id) REFERENCES mappings(class_id) ON DELETE CASCADE
104101 )
105- """
106- )
102+ """ )
107103
108104 conn .commit ()
109105 conn .close ()
@@ -265,15 +261,13 @@ def db_get_untagged_images() -> List[UntaggedImageRecord]:
265261 cursor = conn .cursor ()
266262
267263 try :
268- cursor .execute (
269- """
264+ cursor .execute ("""
270265 SELECT i.id, i.path, i.folder_id, i.thumbnailPath, i.metadata
271266 FROM images i
272267 JOIN folders f ON i.folder_id = f.folder_id
273268 WHERE f.AI_Tagging = TRUE
274269 AND i.isTagged = FALSE
275- """
276- )
270+ """ )
277271
278272 results = cursor .fetchall ()
279273
@@ -457,18 +451,22 @@ def db_toggle_image_favourite_status(image_id: str) -> bool:
457451 finally :
458452 conn .close ()
459453
454+
460455def db_get_image_by_id (image_id : str ) -> Optional [dict ]:
461456 """
462457 Get a single image by ID with its favorite status.
463458 """
464459 conn = _connect ()
465460 cursor = conn .cursor ()
466461 try :
467- cursor .execute ("""
462+ cursor .execute (
463+ """
468464 SELECT id, path, folder_id, thumbnailPath, metadata, isTagged, isFavourite
469465 FROM images
470466 WHERE id = ?
471- """ , (image_id ,))
467+ """ ,
468+ (image_id ,),
469+ )
472470 row = cursor .fetchone ()
473471 if not row :
474472 return None
@@ -488,6 +486,7 @@ def db_get_image_by_id(image_id: str) -> Optional[dict]:
488486 finally :
489487 conn .close ()
490488
489+
491490# ============================================================================
492491# MEMORIES FEATURE - Location and Time-based Queries
493492# ============================================================================
@@ -749,8 +748,7 @@ def db_get_images_with_location() -> List[dict]:
749748 cursor = conn .cursor ()
750749
751750 try :
752- cursor .execute (
753- """
751+ cursor .execute ("""
754752 SELECT
755753 i.id,
756754 i.path,
@@ -770,8 +768,7 @@ def db_get_images_with_location() -> List[dict]:
770768 AND i.longitude IS NOT NULL
771769 GROUP BY i.id
772770 ORDER BY i.captured_at DESC
773- """
774- )
771+ """ )
775772
776773 results = cursor .fetchall ()
777774
@@ -816,8 +813,7 @@ def db_get_all_images_for_memories() -> List[dict]:
816813 cursor = conn .cursor ()
817814
818815 try :
819- cursor .execute (
820- """
816+ cursor .execute ("""
821817 SELECT
822818 i.id,
823819 i.path,
@@ -835,8 +831,7 @@ def db_get_all_images_for_memories() -> List[dict]:
835831 LEFT JOIN mappings m ON ic.class_id = m.class_id
836832 GROUP BY i.id
837833 ORDER BY i.captured_at DESC
838- """
839- )
834+ """ )
840835
841836 results = cursor .fetchall ()
842837
0 commit comments