Add vacuum helper — please read the docstring before using

This commit is contained in:
Claudia Bauer 2026-04-07 17:45:00 +00:00
parent d657c8375a
commit 4c29bcc54c

View file

@ -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}"))