diff options
Diffstat (limited to 'python/report_ops')
| -rw-r--r-- | python/report_ops/remote.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/python/report_ops/remote.py b/python/report_ops/remote.py index 5d66fd7f..944019e1 100644 --- a/python/report_ops/remote.py +++ b/python/report_ops/remote.py @@ -57,18 +57,19 @@ class Report: with cls._sftp.client.open(fname) as fh: return load_citco_report(fh, kd, cls.date_cols) - def to_db(self): - p = self.get_newest_report(self.date) - df = self.to_df(p) - with self._conn.cursor() as c: + @classmethod + def to_db(cls, date): + p = cls.get_newest_report(date) + df = cls.to_df(p) + with cls._conn.cursor() as c: c.execute( - f"DELETE FROM {self.table} WHERE period_end_date= %s", - (self.date,), + f"DELETE FROM {cls.table} WHERE period_end_date= %s", + (date,), ) - self._conn.commit() + cls._conn.commit() if "strategy" in df.columns: df["strategy"] = df["strategy"].str.replace("/M_|/SER_", "/", regex=True) - df.to_sql(self.table, dawn_engine, if_exists="append", index=False) + df.to_sql(cls.table, dawn_engine, if_exists="append", index=False) class AccruedReport( |
