home · contact · privacy
Refactor Process/ProcessStep setting and saving.
[plomtask] / plomtask / db.py
index e0a5d4f5df5426512c8a7552ca889c598dcaabfe..f53a94c4f085f3664d66f0b0cc38863b217741e1 100644 (file)
@@ -2,8 +2,8 @@
 from os.path import isfile
 from difflib import Differ
 from sqlite3 import connect as sql_connect, Cursor
-from typing import Any
-from plomtask.misc import HandledException
+from typing import Any, Dict
+from plomtask.exceptions import HandledException
 
 PATH_DB_SCHEMA = 'scripts/init.sql'
 
@@ -23,7 +23,7 @@ class DatabaseFile:  # pylint: disable=too-few-public-methods
         self._check()
 
     def _check(self) -> None:
-        """Check file exists and is of proper schema."""
+        """Check file exists, and is of proper schema."""
         self.exists = isfile(self.path)
         if self.exists:
             self._validate_schema()
@@ -49,6 +49,11 @@ class DatabaseConnection:
     def __init__(self, db_file: DatabaseFile) -> None:
         self.file = db_file
         self.conn = sql_connect(self.file.path)
+        self.cached_todos: Dict[int, Any] = {}
+        self.cached_days: Dict[str, Any] = {}
+        self.cached_process_steps: Dict[int, Any] = {}
+        self.cached_processes: Dict[int, Any] = {}
+        self.cached_conditions: Dict[int, Any] = {}
 
     def commit(self) -> None:
         """Commit SQL transaction."""