pirogue.utils.update_command

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

Creates an UPDATE 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

  • remove_pkey – if True, the primary key will also be updated

  • pkey – can be manually specified.

  • table_alias – if not specified, table is used

  • 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

  • update_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)

  • where_clause – can be manually specified

  • indent – add 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)

Returns:

the SQL command