pirogue.utils.insert_command

pirogue.utils.insert_command(pg_cur: cursor, table_schema: str, table_name: str, table_type: str = 'table', table_alias: str | None = None, remove_pkey: bool = True, pkey: str | None = None, coalesce_pkey_default: bool = False, skip_columns: list = [], comment_skipped: bool = True, remap_columns: dict = {}, insert_values: dict = {}, columns_on_top: list = [], columns_at_end: list = [], prefix: str | None = None, returning: str | None = None, indent: int = 2, inner_defaults: dict = {}) str[source]

Creates an INSERT command

Parameters:
  • pg_cur – the psycopg cursor

  • table_schema – the schema

  • table_name – the name of the table

  • table_type – the type of table, i.e. view or table

  • table_alias – the alias of the table

  • remove_pkey – if True, the primary is removed from the list

  • pkey – can be manually specified.

  • coalesce_pkey_default – if True, the following expression is used to insert the primary key: COALESCE( NEW.{pkey}, {default_value} )

  • skip_columns – list of columns to be skipped

  • comment_skipped – if True, skipped columns are written but commented, otherwise they are not written

  • remap_columns – dictionary to remap columns

  • insert_values – dictionary of expression to be used at insert

  • columns_on_top – bring the columns to the front of the list

  • columns_at_end – bring the columns to the end of the list

  • prefix – add a prefix to the columns (do not applied to remapped columns)

  • returning – returning command

  • add (indent) – an indent in front

  • inner_defaults – dictionary of other columns to default to in case the provided value is null (can be used instead of insert_values to make it easier to reuse other columns definitions)