Add Redshift writer
This commit is contained in:
parent
21fb333812
commit
f9d124ab6f
1 changed files with 8 additions and 0 deletions
8
src/load/redshift_writer.py
Normal file
8
src/load/redshift_writer.py
Normal file
|
|
@ -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
|
||||||
Loading…
Reference in a new issue