pgcom.commuter.Commuter.copy_from

Commuter.copy_from(table_name: str, data: pandas.core.frame.DataFrame, format_data: bool = False, sep: str = ',', na_value: str = '', where: Optional[Union[str, psycopg2.sql.Composed]] = None) None[source]

Places DataFrame to a buffer and apply COPY FROM command.

Parameters
  • table_name – Name of the table where to insert.

  • data – DataFrame from where to insert.

  • format_data – Reorder columns and adjust dtypes wrt to table metadata from information_schema.

  • sep – String of length 1. Field delimiter for the output file. Defaults to “,”.

  • na_value – Missing data representation, defaults to “”.

  • where – WHERE clause used to specify a condition while deleting data from the table before applying copy_from, DELETE command is not executed if not specified.

Raises

CopyError – if execution fails.