{"id":3399,"library":"apache-airflow-providers-oracle","title":"Apache Airflow Oracle Provider","description":"The Apache Airflow Oracle Provider enables Airflow to interact with Oracle databases. It includes hooks and operators to execute SQL commands, manage data, and transfer data between Oracle instances. As of version 4.5.2, it leverages the modern `oracledb` driver for Python 3.10+ and is actively maintained, with releases often aligned with Apache Airflow's own release cycle or independently for bug fixes and features.","status":"active","version":"4.5.2","language":"en","source_language":"en","source_url":"https://github.com/apache/airflow/tree/main/airflow/providers/oracle","tags":["airflow","oracle","database","provider","sql"],"install":[{"cmd":"pip install apache-airflow-providers-oracle","lang":"bash","label":"Install provider"}],"dependencies":[{"reason":"Core Airflow functionality is required to use providers.","package":"apache-airflow","optional":false},{"reason":"Official Oracle Database API for Python, recommended over the deprecated `cx_oracle` for Python 3.10+.","package":"oracledb","optional":false}],"imports":[{"note":"Used for programmatic interaction with Oracle databases in Airflow tasks.","symbol":"OracleHook","correct":"from airflow.providers.oracle.hooks.oracle import OracleHook"},{"note":"Executes SQL commands against an Oracle database. Most common operator.","symbol":"OracleOperator","correct":"from airflow.providers.oracle.operators.oracle import OracleOperator"},{"note":"Transfers data directly between two Oracle connections.","symbol":"OracleToOracleOperator","correct":"from airflow.providers.oracle.transfers.oracle_to_oracle import OracleToOracleOperator"}],"quickstart":{"code":"from __future__ import annotations\n\nimport pendulum\n\nfrom airflow.models.dag import DAG\nfrom airflow.providers.oracle.operators.oracle import OracleOperator\n\n# Ensure an Airflow connection named 'oracle_default' exists with Oracle DB details.\n# In the Airflow UI (Admin -> Connections -> +), create a new connection:\n# - Conn Id: oracle_default\n# - Conn Type: Oracle\n# - Host: your_oracle_host\n# - Port: 1521 (or your port)\n# - Schema: your_service_name_or_sid\n# - Login: your_username\n# - Password: your_password\n\nwith DAG(\n    dag_id=\"oracle_example_dag\",\n    start_date=pendulum.datetime(2023, 1, 1, tz=\"UTC\"),\n    catchup=False,\n    schedule=None,\n    tags=[\"oracle\", \"example\", \"database\"],\n) as dag:\n    create_table = OracleOperator(\n        task_id=\"create_test_table\",\n        oracle_conn_id=\"oracle_default\",\n        sql=\"\"\"\n        CREATE TABLE IF NOT EXISTS AIRFLOW_TEST_TABLE (\n            ID NUMBER PRIMARY KEY,\n            NAME VARCHAR2(50)\n        )\n        \"\"\",\n        autocommit=True,\n    )\n\n    insert_data = OracleOperator(\n        task_id=\"insert_data_into_table\",\n        oracle_conn_id=\"oracle_default\",\n        sql=\"\"\"\n        INSERT INTO AIRFLOW_TEST_TABLE (ID, NAME) VALUES (1, 'Test User')\n        \"\"\",\n        autocommit=True,\n    )\n\n    create_table >> insert_data","lang":"python","description":"This quickstart demonstrates a simple Airflow DAG using the `OracleOperator` to create a table and insert data into an Oracle database. Before running, configure an 'Oracle' connection in the Airflow UI with `Conn Id: oracle_default` and your Oracle database credentials."},"warnings":[{"fix":"Uninstall `cx_oracle` if present (`pip uninstall cx_oracle`) and ensure `oracledb` is installed (`pip install oracledb`). The provider's `setup.py` usually handles this correctly on installation if `cx_oracle` is not already present.","message":"The Oracle provider, especially for Python 3.10+, now primarily relies on the `oracledb` library. If you were previously using `cx_oracle`, ensure you transition to `oracledb`.","severity":"breaking","affected_versions":"All versions of `apache-airflow-providers-oracle` from 4.x onwards prefer `oracledb`."},{"fix":"For thick mode, download and install Oracle Instant Client, then ensure the appropriate `LD_LIBRARY_PATH` (Linux/macOS) or `PATH` (Windows) environment variable is set in the environment where Airflow workers run, or use `oracledb.init_oracle_client()` with the library directory.","message":"`oracledb` can operate in 'thin mode' (no client libraries required) or 'thick mode' (requires Oracle Client libraries like Instant Client). Thick mode is necessary for features like Connection Pooling, Two-Phase Commits, or advanced data types. Many users forget to configure client libraries for thick mode.","severity":"gotcha","affected_versions":"All versions using `oracledb` or `cx_oracle`."},{"fix":"Verify with your DBA whether to use Service Name or SID. For Service Name, it's typically 'ServiceName' (e.g., `ORCLCDB`); for SID, it's 'SID' (e.g., `ORCL`). If using TNS, ensure the `TNS_ADMIN` environment variable is correctly set for the Airflow process and points to the directory containing your `tnsnames.ora` file.","message":"Correctly configuring the Oracle Airflow Connection in the UI can be tricky. Pay attention to 'Schema' field, which can be either the Service Name or the SID, depending on your Oracle setup. Also, `TNS_ADMIN` environment variable can be used for TNS entry resolution but must be configured for the Airflow worker.","severity":"gotcha","affected_versions":"All versions."}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}