snowflake.snowpark.DataFrameWriter.insert_into¶
- DataFrameWriter.insert_into(table_name: Union[str, Iterable[str]], overwrite: bool = False) None [source]¶
Inserts the content of the DataFrame to the specified table. It requires that the schema of the DataFrame is the same as the schema of the table.
- Parameters:
table_name – A string or list of strings representing table name. If input is a string, it represents the table name; if input is of type iterable of strings, it represents the fully-qualified object identifier (database name, schema name, and table name).
overwrite – If True, the content of table will be overwritten. If False, the data will be appended to the table. Default is False.
Example:
>>> # save this dataframe to a json file on the session stage >>> df = session.create_dataframe([["John", "Berry"]], schema = ["FIRST_NAME", "LAST_NAME"]) >>> df.write.save_as_table("my_table", table_type="temporary") >>> df2 = session.create_dataframe([["Rick", "Berry"]], schema = ["FIRST_NAME", "LAST_NAME"]) >>> df2.write.insert_into("my_table") >>> session.table("my_table").collect() [Row(FIRST_NAME='John', LAST_NAME='Berry'), Row(FIRST_NAME='Rick', LAST_NAME='Berry')]