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:
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 |
Password: string |
Vertica database user password |
Port: int |
Vertica database port (default: 5433) |
Extra: JSON |
Additional connection configuration (e.g. TLS settings):
|
An example usage of the SQLExecuteQueryOperator
to connect to Vertica is as follows:
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).