forked from Rockachopa/Timmy-time-dashboard
Review Fix: Improve src/infrastructure/chat_store.py
This commit is contained in:
@@ -60,7 +60,12 @@ class MessageLog:
|
||||
self._conn: sqlite3.Connection | None = None
|
||||
|
||||
# Lazy connection — opened on first use, not at import time.
|
||||
def _ensure_conn(self) -> sqlite3.Connection:
|
||||
@contextmanager
|
||||
def _get_conn(self) -> Generator[sqlite3.Connection, None, None]:
|
||||
path = self._db_path or DB_PATH
|
||||
with closing(sqlite3.connect(str(path), check_same_thread=False)) as conn:
|
||||
conn.row_factory = sqlite3.Row
|
||||
yield conn
|
||||
if self._conn is None:
|
||||
# Open a persistent connection for the class instance
|
||||
path = self._db_path or DB_PATH
|
||||
|
||||
Reference in New Issue
Block a user