This is an automated email from the ASF dual-hosted git repository.

vatsrahul1001 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 0f0fb954230 Fix Postgres tutorial for psycopg3 (#72562)
0f0fb954230 is described below

commit 0f0fb954230da6c96bfc22391ffaaa61312c12ea
Author: Ayodya Enhanayoan <[email protected]>
AuthorDate: Thu Sep 10 03:18:53 2026 +0700

    Fix Postgres tutorial for psycopg3 (#72562)
    
    * Fix Postgres tutorial for psycopg3
    
    Use PostgresHook.copy_expert() instead of calling copy_expert()
    on the raw cursor, ensuring the tutorial works with psycopg3.
    
    * Fix pipeline tutorial formatting
---
 airflow-core/docs/tutorial/pipeline.rst | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/airflow-core/docs/tutorial/pipeline.rst 
b/airflow-core/docs/tutorial/pipeline.rst
index 196ee7857bb..4768a444b98 100644
--- a/airflow-core/docs/tutorial/pipeline.rst
+++ b/airflow-core/docs/tutorial/pipeline.rst
@@ -175,14 +175,10 @@ Next, we'll download a CSV file, save it locally, and 
load it into ``employees_t
           file.write(response.text)
 
       postgres_hook = PostgresHook(postgres_conn_id="tutorial_pg_conn")
-      conn = postgres_hook.get_conn()
-      cur = conn.cursor()
-      with open(data_path, "r") as file:
-          cur.copy_expert(
-              "COPY employees_temp FROM STDIN WITH CSV HEADER DELIMITER AS ',' 
QUOTE '\"'",
-              file,
-          )
-      conn.commit()
+      postgres_hook.copy_expert(
+          "COPY employees_temp FROM STDIN WITH CSV HEADER DELIMITER AS ',' 
QUOTE '\"'",
+          data_path,
+      )
 
 This task gives you a taste of combining Airflow with native Python and SQL 
hooks -- a common pattern in real-world
 pipelines.
@@ -292,14 +288,10 @@ Now that we've defined all our tasks, it's time to put 
them together into a Dag.
               file.write(response.text)
 
           postgres_hook = PostgresHook(postgres_conn_id="tutorial_pg_conn")
-          conn = postgres_hook.get_conn()
-          cur = conn.cursor()
-          with open(data_path, "r") as file:
-              cur.copy_expert(
-                  "COPY employees_temp FROM STDIN WITH CSV HEADER DELIMITER AS 
',' QUOTE '\"'",
-                  file,
-              )
-          conn.commit()
+          postgres_hook.copy_expert(
+              "COPY employees_temp FROM STDIN WITH CSV HEADER DELIMITER AS ',' 
QUOTE '\"'",
+              data_path,
+          )
 
       @task
       def merge_data():

Reply via email to