fix: SQLite 연결 체크 강화

- 커서 생성/실행/close로 연결 상태 확인
- 연결 닫힐 때 명시적 close 호출
- I/O operation on closed file 에러 방지
This commit is contained in:
thug0bin 2026-02-27 15:41:28 +09:00
parent d44aed16be
commit 870e40a6db

View File

@ -193,11 +193,20 @@ class DatabaseManager:
Returns:
sqlite3.Connection: SQLite 연결 객체
"""
# 연결이 닫혀있으면 재생성
# 연결 유효성 체크 강화
if self.sqlite_conn is not None:
try:
self.sqlite_conn.execute("SELECT 1")
except Exception:
# 연결 상태 확인
cursor = self.sqlite_conn.cursor()
cursor.execute("SELECT 1")
cursor.fetchone()
cursor.close()
except Exception as e:
print(f"[DB Manager] SQLite 연결 체크 실패, 재연결: {e}")
try:
self.sqlite_conn.close()
except:
pass
self.sqlite_conn = None
if self.sqlite_conn is None: