From f9d124ab6fee81a43147db7e12417aa5b853dc9c Mon Sep 17 00:00:00 2001 From: Claudia Bauer Date: Thu, 29 Jan 2026 10:00:00 +0000 Subject: [PATCH] Add Redshift writer --- src/load/redshift_writer.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/load/redshift_writer.py diff --git a/src/load/redshift_writer.py b/src/load/redshift_writer.py new file mode 100644 index 0000000..400fe59 --- /dev/null +++ b/src/load/redshift_writer.py @@ -0,0 +1,8 @@ +import pandas as pd +from sqlalchemy import create_engine, text + + +def write_to_redshift(df: pd.DataFrame, table: str, conn_str: str, if_exists: str = "append") -> int: + 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