This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def upsert_df(self, df: pd.DataFrame, table_name: str) -> None: | |
""" | |
Implements the equivalent of pd.DataFrame.to_sql(..., if_exists='update') (which does not exist). Creates or updates the db records based on the dataframe records. | |
Parameters: | |
df (pd.DataFrame): Dataframe to upsert (NOTE: Primary keys of the destination 'table_name' must be equal to dataframe index and not present in the dataframe columns) | |
table_name (str): Table name | |
client (PostgresClient): Database client | |
Returns: | |
None | |
""" |