+
+
+class DatabaseConnection:
+ """A single connection to the database."""
+
+ 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."""
+ self.conn.commit()
+
+ def exec(self, code: str, inputs: tuple[Any, ...] = tuple()) -> Cursor:
+ """Add commands to SQL transaction."""
+ return self.conn.execute(code, inputs)
+
+ def close(self) -> None:
+ """Close DB connection."""
+ self.conn.close()