airflow.providers.postgres.operators.postgres

Module Contents

Classes

PostgresOperator

Executes sql code in a specific Postgres database

class airflow.providers.postgres.operators.postgres.PostgresOperator(*, sql, postgres_conn_id='postgres_default', autocommit=False, parameters=None, database=None, runtime_parameters=None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Executes sql code in a specific Postgres database

Parameters
  • sql (Union[str, List[str]]) -- the SQL code to be executed as a single string, or a list of str (sql statements), or a reference to a template file. Template references are recognized by str ending in '.sql'

  • postgres_conn_id (str) -- The postgres conn id reference to a specific postgres database.

  • autocommit (bool) -- if True, each command is automatically committed. (default value: False)

  • parameters (Optional[Union[Mapping, Iterable]]) -- (optional) the parameters to render the SQL query with.

  • database (Optional[str]) -- name of database which overwrite defined one in connection

template_fields :Sequence[str] = ['sql'][source]
template_fields_renderers[source]
template_ext :Sequence[str] = ['.sql'][source]
ui_color = #ededed[source]
execute(self, context)[source]

This is the main method to derive when creating an operator. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

Was this entry helpful?