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

vatsrahul1001 pushed a commit to branch v3-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-3-test by this push:
     new c1e2711d619 [v3-3-test] Fix Postgres tutorial for psycopg3 (#72562) 
(#72837)
c1e2711d619 is described below

commit c1e2711d619a7d60a32f9c74b3aed2e6c5c44d5c
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Sep 10 16:27:28 2026 +0530

    [v3-3-test] Fix Postgres tutorial for psycopg3 (#72562) (#72837)
    
    * 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
    (cherry picked from commit 0f0fb954230da6c96bfc22391ffaaa61312c12ea)
    
    Co-authored-by: Ayodya Enhanayoan 
<[email protected]>
    Co-authored-by: Rahul Vats <[email protected]>
---
 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