pythonpostgresqlairflowdocumentairflow-2.x

How exactly to understand documentations without any explanation in Airflow?


I try to understand The PostgresHook in Airflow. Here is the documentation:

https://airflow.apache.org/docs/apache-airflow/1.10.6/_api/airflow/hooks/postgres_hook/index.html

Now for example if I wanna understand the function

get_conn(self)

I know know what it does, but as a beginner in general, how can I understand how this function works, if there is literally no explanation in the documentation? There is only a link to the source code and that's it. So this means, to understand how the function works, I have to check the source code, right? This is a common way, how these documentations works?


Solution

  • Be sure to look at the version and ensure that the version matches what you're running. You posted a link to version 1.10.6, which is about 4 years old. In Airflow 2, all the former "contrib" packages were moved into "provider" packages. If you are using a more recent version of Airflow, all the sql operators were abstracted to the commons.sql provider and you can find the code (including doc strings) in the python API page by clicking into the items.

    To your question about get_conn method in the postgres hook, here is a link to the code where you can see it take the information from your connection and use psycopg2 library to create a connection. This has been consistent across versions.