SQLExecuteQueryOperator to connect to Vertica

Use the SQLExecuteQueryOperator to execute Vertica commands in a Vertica database.

Note

If you previously used other legacy operators to handle Vertica interactions, you can now use SQLExecuteQueryOperator for both stored procedures and raw SQL execution.

Using the Operator

Use the conn_id argument to connect to your Vertica instance where the connection metadata is structured as follows:

Vertica Airflow Connection Metadata

Parameter

Input

Host: string

Vertica database hostname or container name (if running in Docker network)

Schema: string

Schema to execute SQL operations on by default

Login: string

Vertica database user (often dbadmin if using community Docker image)

Password: string

Vertica database user password

Port: int

Vertica database port (default: 5433)

Extra: JSON

Additional connection configuration (e.g. TLS settings): {"tlsmode": "disable"}

An example usage of the SQLExecuteQueryOperator to connect to Vertica is as follows:

vertica/tests/system/vertica/example_vertica.py[source]


    create_table_vertica_task = SQLExecuteQueryOperator(
        task_id="create_table_vertica",
        sql=[
            "DROP TABLE IF EXISTS employees;",
            """
            CREATE TABLE employees (
                id IDENTITY,
                name VARCHAR(50),
                salary NUMERIC(10,2),
                hire_date TIMESTAMP DEFAULT NOW()
            )
            """,
        ],
    )

Reference

For further information, look at:

Note

Parameters given via SQLExecuteQueryOperator() take first-place priority relative to parameters set via the Airflow connection metadata (such as schema, login, password, etc).

Was this entry helpful?