diff options
Diffstat (limited to 'python/citco_ops')
| -rw-r--r-- | python/citco_ops/remote.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/python/citco_ops/remote.py b/python/citco_ops/remote.py index 7570aa62..5ec50028 100644 --- a/python/citco_ops/remote.py +++ b/python/citco_ops/remote.py @@ -53,7 +53,10 @@ class Report: if self.fname in filename if type(self).ped_func(filename).date() == self.date ] - return max(report_files, key=type(self).ped_func) + try: + return max(report_files, key=type(self).ped_func) + except ValueError: + raise ValueError(f"Missing data for {self.table}: {self.date}") def to_df(self): with self._sftp.client.open(self.most_recent_report) as fh: @@ -62,13 +65,13 @@ class Report: ) def to_db(self): + df = self.to_df() with self._conn.cursor() as c: c.execute( f"DELETE FROM {self.table} WHERE period_end_date= %s", (self.date,), ) self._conn.commit() - df = self.to_df() df.to_sql(self.table, dawn_engine, if_exists="append", index=False) |
