Airflow Summit 2025 is coming October 07-09. Register now for early bird ticket!

SQLExecuteQueryOperator to connect to Exasol

Use the SQLExecuteQueryOperator to execute SQL commands in an Exasol database.

Note

Previously, an ExasolOperator was used to perform this kind of operation. After deprecation this has been removed. Please use SQLExecuteQueryOperator instead.

Note

Make sure you have installed the apache-airflow-providers-exasol package and its dependency pyexasol to enable Exasol support.

Using the Operator

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

Exasol Airflow Connection Metadata

Parameter

Input

Host: string

Exasol hostname, container alias or IP address

Schema: string

Default schema name (e.g. TEST) (optional)

Login: string

Exasol username (e.g. TEST or sys)

Password: string

Exasol password

Port: int

Exasol port (default: 8563)

Extra: JSON

Additional connection configuration passed to pyexasol, such as: {"encryption": false} or {"encryption": true, "websocket_sslopt": {"cert_reqs": 0}}

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

tests/system/exasol/example_exasol.py[source]

    create_table_exasol = SQLExecuteQueryOperator(
        task_id="create_table_exasol",
        sql="""
            CREATE OR REPLACE TABLE exasol_example (
                a VARCHAR(100),
                b DECIMAL(18,0)
            );
        """,
    )

    alter_table_exasol = SQLExecuteQueryOperator(
        task_id="alter_table_exasol",
        sql="ALTER TABLE exasol_example ADD COLUMN c DECIMAL(18,0);",
    )

    insert_data_exasol = SQLExecuteQueryOperator(
        task_id="insert_data_exasol",
        sql="""
            INSERT INTO exasol_example (a, b, c)
            VALUES
              ('a', 1, 1),
              ('a', 2, 1),
              ('b', 3, 1);
        """,
    )

    select_data_exasol = SQLExecuteQueryOperator(
        task_id="select_data_exasol",
        sql="SELECT * FROM exasol_example;",
    )

    drop_table_exasol = SQLExecuteQueryOperator(
        task_id="drop_table_exasol",
        sql="DROP TABLE exasol_example;",
    )

Reference

For further information, look at:

Note

Parameters provided directly via SQLExecuteQueryOperator() take precedence over those specified in the Airflow connection metadata (such as schema, login, password, etc).

Was this entry helpful?