diff --git a/pyulog/db.py b/pyulog/db.py index dc0434b..d28acb3 100644 --- a/pyulog/db.py +++ b/pyulog/db.py @@ -170,6 +170,7 @@ def __init__(self, db_handle, primary_key=None, log_file=None, lazy=True, **kwar self._pk = primary_key self._db = db_handle + self._lazy_loaded = lazy if log_file is not None: self._sha256sum = DatabaseULog.calc_sha256sum(log_file) @@ -187,6 +188,11 @@ def __eq__(self, other): return other.__eq__(self) return super().__eq__(other) + def write_ulog(self, path): + if self._lazy_loaded: + raise ValueError('Cannot write after lazy load because it has no datasets.') + super().write_ulog(path) + @property def primary_key(self): '''The primary key of the ulog, pointing to the correct "ULog" row in the database.''' @@ -400,6 +406,7 @@ def load(self, lazy=True): self._changed_parameters.append((timestamp, key, value)) cur.close() + self._lazy_loaded = lazy def get_dataset(self, name, multi_instance=0, lazy=False, db_cursor=None, caching=True): '''