{"id":2386,"library":"apache-airflow-providers-postgres","title":"Apache Airflow Postgres Provider","description":"The Apache Airflow Postgres Provider offers a comprehensive set of operators, hooks, and sensors for seamless interaction with PostgreSQL databases within Airflow DAGs. It enables tasks such as executing SQL queries, transferring data, and managing database connections. The current version is 6.6.2, and it follows a frequent release cadence to support new Airflow features and address issues.","status":"active","version":"6.6.2","language":"en","source_language":"en","source_url":"https://airflow.apache.org/docs/apache-airflow-providers-postgres/stable/index.html","tags":["airflow","database","postgres","provider","etl","sql"],"install":[{"cmd":"pip install apache-airflow-providers-postgres","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core dependency for any Airflow provider. Requires Airflow >=2.11.0 for provider version 6.5.0 and newer.","package":"apache-airflow","optional":false},{"reason":"PostgreSQL adapter for Python. Specific version requirements depend on Python version.","package":"psycopg2-binary","optional":false},{"reason":"Provides common compatibility utilities for Airflow providers.","package":"apache-airflow-providers-common-compat","optional":false},{"reason":"Provides common SQL functionalities and base operators/hooks for SQL-based providers.","package":"apache-airflow-providers-common-sql","optional":false},{"reason":"Optional dependency for asynchronous PostgreSQL operations (requires >=0.30.0).","package":"asyncpg","optional":true},{"reason":"Optional dependency for certain PostgresHook methods that return pandas DataFrames.","package":"pandas","optional":true},{"reason":"Optional dependency for certain PostgresHook methods that return polars DataFrames.","package":"polars","optional":true}],"imports":[{"note":"Old import path for Airflow 1.x series; Airflow 2.x and providers use the fully qualified provider path.","wrong":"from airflow.operators.postgres_operator import PostgresOperator","symbol":"PostgresOperator","correct":"from airflow.providers.postgres.operators.postgres import PostgresOperator"},{"note":"Old import path for Airflow 1.x (contrib) series; Airflow 2.x and providers use the fully qualified provider path.","wrong":"from airflow.contrib.hooks.postgres_hook import PostgresHook","symbol":"PostgresHook","correct":"from airflow.providers.postgres.hooks.postgres import PostgresHook"}],"quickstart":{"code":"import datetime\nfrom airflow import DAG\nfrom airflow.providers.postgres.operators.postgres import PostgresOperator\n\nwith DAG(\n    dag_id=\"postgres_example_dag\",\n    start_date=datetime.datetime(2023, 1, 1),\n    schedule_interval=\"@once\",\n    catchup=False,\n    tags=[\"postgres\", \"example\"]\n) as dag:\n    create_pet_table = PostgresOperator(\n        task_id=\"create_pet_table\",\n        postgres_conn_id=\"postgres_default\",\n        sql=\"\"\"\n            CREATE TABLE IF NOT EXISTS pet (\n            pet_id SERIAL PRIMARY KEY,\n            name VARCHAR NOT NULL,\n            pet_type VARCHAR NOT NULL,\n            birth_date DATE NOT NULL,\n            owner VARCHAR NOT NULL\n            );\n        \"\"\"\n    )\n\n    populate_pet_table = PostgresOperator(\n        task_id=\"populate_pet_table\",\n        postgres_conn_id=\"postgres_default\",\n        sql=\"\"\"\n            INSERT INTO pet (name, pet_type, birth_date, owner)\n            VALUES ('Fido', 'Dog', '2020-01-01', 'Alice'),\n                   ('Whiskers', 'Cat', '2019-05-15', 'Bob');\n        \"\"\"\n    )\n\n    create_pet_table >> populate_pet_table","lang":"python","description":"This example DAG defines two tasks using the `PostgresOperator`. The first task creates a 'pet' table if it doesn't already exist, and the second task populates it with sample data. Ensure you have an Airflow connection named 'postgres_default' configured in the Airflow UI, pointing to your PostgreSQL instance."},"warnings":[{"fix":"Upgrade your Apache Airflow instance to version 2.11.0 or later, or use an older provider version compatible with your Airflow installation.","message":"Provider version 6.5.0 and later require Apache Airflow 2.11.0 or newer. Older Airflow versions will not be able to install or run these provider versions.","severity":"breaking","affected_versions":">=6.5.0"},{"fix":"Update any usage of `schema` in `PostgresHook` or related classes to use `database` instead.","message":"In provider version 6.6.2 (released March 28, 2026), the `schema` argument in Postgres hooks (e.g., `PostgresHook`) has been renamed to `database`. Using `schema` will now raise an error.","severity":"breaking","affected_versions":">=6.6.2"},{"fix":"Update any code that parses or expects the `postgres://` prefix from `get_uri()` to handle `postgresql://`.","message":"Beginning with provider version 4.0.0, the `get_uri()` method of `PostgresHook` returns a URI with the `postgresql://` prefix instead of the older `postgres://` prefix. This aligns with SQLAlchemy 1.4.0+ requirements.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Migrate from `runtime_parameters` to using `hook_params={'options': {'your_param': 'value'}}` for passing runtime configuration.","message":"The `runtime_parameters` argument in `PostgresOperator` was deprecated in favor of passing options via `hook_params` in provider version 5.5.2.","severity":"deprecated","affected_versions":">=5.5.2"},{"fix":"Ensure your Airflow environment is running on Python 3.10 or higher. Check the `requires_python` field for precise version compatibility.","message":"Python 3.7 support was dropped in provider version 5.5.1. The current provider version requires Python >=3.10.","severity":"gotcha","affected_versions":">=5.5.1"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}