mik-laj commented on a change in pull request #16548:
URL: https://github.com/apache/airflow/pull/16548#discussion_r654918088
##########
File path: docs/apache-airflow/tutorial.rst
##########
@@ -426,17 +407,16 @@ Let's break this down into 3 steps: get data, insert
data, merge data:
for row in response.text.split("\n"):
file.write(row)
-Here we are passing a``GET`` request to get the data from the URL and save it
in ``employees.csv`` file on our Airflow instance.
+Here we are passing a`GET` request to get the data from the URL and save it in
`employees.csv` file on our Airflow instance.
.. code-block:: python
@task
def insert_data():
- engine = create_engine(
- "postgresql+psycopg2://postgres:password@localhost:5432/postgres"
- )
+ postgres_hook = PostgresHook(postgres_conn_id="LOCAL")
+ conn = postgres_hook.get_conn()
df = pd.read_csv("/usr/local/airflow/dags/files/employees.csv")
- df.to_sql("Employees_temp", con=engine, if_exists="replace",
chunksize=1000)
+ df.to_sql("Employees_temp", conn, if_exists="replace", chunksize=1000)
Review comment:
Are you sure if it works? Based on Pandas documentation, Dataframe
supports [`sqlalchemy.engine.(Engine or Connection) or
sqlite3.Connection`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_sql.html)
only. Here, we have `psycopg2.extensions.connection`?
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]