fix: AI 추천 이미지 조회 시 sqlite3 import 누락 수정

- sqlite3 모듈 import 추가
- 디버그 로그 추가
This commit is contained in:
thug0bin 2026-03-03 00:31:42 +09:00
parent 8aa43221d2
commit 79259d004b

View File

@ -23,6 +23,7 @@ from sqlalchemy import text
from dotenv import load_dotenv
import json
import time
import sqlite3
from pathlib import Path
# 환경 변수 로드 (명시적 경로)
@ -2413,11 +2414,13 @@ def api_get_recommendation(user_id):
product_image = None
try:
img_db_path = os.path.join(os.path.dirname(__file__), 'db', 'product_images.db')
logging.info(f"[AI추천] 이미지 DB 경로: {img_db_path}")
img_conn = sqlite3.connect(img_db_path)
img_conn.row_factory = sqlite3.Row
img_cursor = img_conn.cursor()
product_name = rec['recommended_product']
logging.info(f"[AI추천] 검색할 제품명: {product_name}")
# 제품명으로 이미지 검색 (LIKE 검색으로 부분 매칭)
img_cursor.execute("""
SELECT thumbnail_base64 FROM product_images
@ -2427,6 +2430,9 @@ def api_get_recommendation(user_id):
img_row = img_cursor.fetchone()
if img_row:
product_image = img_row['thumbnail_base64']
logging.info(f"[AI추천] 이미지 찾음: {len(product_image)} bytes")
else:
logging.info(f"[AI추천] 이미지 없음 (제품: {product_name})")
img_conn.close()
except Exception as e:
logging.warning(f"[AI추천] 제품 이미지 조회 실패: {e}")