You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- upsert: Perform an upsert which checks for conflicts on columns given by ``upsert_conflict_columns`` and sets the new values on conflicts. Note that column names of the Dataframe will be used for this operation, as if ``use_column_names`` was set to True.
466
+
461
467
index : bool
462
468
True to store the DataFrame index as a column in the table,
463
469
otherwise False to ignore it.
@@ -471,6 +477,8 @@ def to_sql(
471
477
If set to True, will use the column names of the DataFrame for generating the INSERT SQL Query.
472
478
E.g. If the DataFrame has two columns `col1` and `col3` and `use_column_names` is True, data will only be
473
479
inserted into the database columns `col1` and `col3`.
480
+
uspert_conflict_columns: List[str], optional
481
+
List of columns to be used as conflict columns in the upsert operation.
474
482
chunksize: int
475
483
Number of rows which are inserted with each SQL query. Defaults to inserting 200 rows per query.
476
484
fast_executemany: bool
@@ -506,6 +514,8 @@ def to_sql(
506
514
ifdf.emptyisTrue:
507
515
raiseexceptions.EmptyDataFrame("DataFrame cannot be empty.")
508
516
_validate_connection(con=con)
517
+
ifmode=="upsert"andnotupsert_conflict_columns:
518
+
raiseexceptions.InvalidArgumentValue("<upsert_conflict_columns> need to be set when using upsert mode.")
0 commit comments