pgcom.commuter.Commuter.resolve_foreign_conflicts

Commuter.resolve_foreign_conflicts(table_name: str, parent_name: str, data: pandas.core.frame.DataFrame, where: Optional[Union[str, psycopg2.sql.Composed]] = None) pandas.core.frame.DataFrame[source]

Resolve foreign key conflicts in DataFrame.

Remove all the rows from the DataFrame conflicted with foreign key constraint.

Parameter where is used to reduce the amount of querying data.

Parameters
  • table_name – Name of the child table, where the data needs to be inserted.

  • parent_name – Name of the parent table.

  • data – DataFrame with foreign key conflicts.

  • where – WHERE clause used when querying from the table_name.

Returns

DataFrame without foreign key conflicts.