You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/10/26 02:00:17 UTC
[GitHub] [airflow] KianYang-Lee commented on a change in pull request #19186: Improving tutorial documentation and code
KianYang-Lee commented on a change in pull request #19186:
URL: https://github.com/apache/airflow/pull/19186#discussion_r736085128
##########
File path: docs/apache-airflow/tutorial.rst
##########
@@ -377,73 +377,85 @@ We need to have docker and postgres installed.
We will be using this `docker file <https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html#docker-compose-yaml>`_
Follow the instructions properly to set up Airflow.
-Create a Employee table in postgres using this
+Create a Employee table in postgres using this:
.. code-block:: sql
- create table "Employees"
+ CREATE TABLE "Employees"
(
- "Serial Number" numeric not null
- constraint employees_pk
- primary key,
- "Company Name" text,
- "Employee Markme" text,
- "Description" text,
- "Leave" integer
+ "Serial Number" NUMERIC PRIMARY KEY,
+ "Company Name" TEXT,
+ "Employee Markme" TEXT,
+ "Description" TEXT,
+ "Leave" INTEGER
);
- create table "Employees_temp"
+ CREATE TABLE "Employees_temp"
(
- "Serial Number" numeric not null
- constraint employees_temp_pk
- primary key,
- "Company Name" text,
- "Employee Markme" text,
- "Description" text,
- "Leave" integer
+ "Serial Number" NUMERIC PRIMARY KEY,
+ "Company Name" TEXT,
+ "Employee Markme" TEXT,
+ "Description" TEXT,
+ "Leave" INTEGER
);
+We also need to add a connection to postgres. Go to the UI and click "Admin" >> "Connections". Specify the following for each field:
+
+- Conn id: LOCAL
+- Conn Type: postgres
+- Host: postgres
+- Schema: <DATABASE_NAME>
+- Login: airflow
+- Password: airflow
+- Port: 5432
+
+After that, you can test your connection and if you followed all the steps correctly, it should show a success notification. Proceed with saving the connection and we are now ready write the DAG.
Let's break this down into 2 steps: get data & merge data:
.. code-block:: python
+ from airflow.decorators import dag, task
+ from airflow.hooks.postgres_hook import PostgresHook
Review comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org