From 4c29bcc54c5c2ce84a45b5da6253e3077ca7ee8c Mon Sep 17 00:00:00 2001 From: Claudia Bauer Date: Tue, 7 Apr 2026 17:45:00 +0000 Subject: [PATCH] =?UTF-8?q?Add=20vacuum=20helper=20=E2=80=94=20please=20re?= =?UTF-8?q?ad=20the=20docstring=20before=20using?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/load/redshift_writer.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/load/redshift_writer.py b/src/load/redshift_writer.py index 400fe59..b632903 100644 --- a/src/load/redshift_writer.py +++ b/src/load/redshift_writer.py @@ -6,3 +6,11 @@ def write_to_redshift(df: pd.DataFrame, table: str, conn_str: str, if_exists: st engine = create_engine(conn_str) rows = df.to_sql(table, engine, if_exists=if_exists, index=False, method="multi", chunksize=1000) return rows or 0 + + +def vacuum_table(table: str, conn_str: str) -> None: + """Run VACUUM on a table. Do not run during business hours. + I learned this the hard way. - c.bauer""" + engine = create_engine(conn_str) + with engine.connect() as conn: + conn.execute(text(f"VACUUM FULL {table}"))