uranusjr commented on a change in pull request #16686:
URL: https://github.com/apache/airflow/pull/16686#discussion_r660207670
##########
File path: docs/apache-airflow/macros-ref.rst
##########
@@ -97,6 +99,13 @@ It is also possible to fetch a variable by string if needed
with
``{{ var.json.get('my.dict.var', {'key1': 'val1'}) }}``. Defaults can be
supplied in case the variable does not exist.
+Similarly, Airflow Connections data can be accessed via the ``conn`` template
variable.
+For example, you could use expressions in your templates like ``{{
conn.my_conn_id.login }}``,
+``{{ conn.my_conn_id.password }}``, etc.
+Just like with ``var`` it's possible to fetch a connection by string or
provide defaults with
+``{{ conn.get('my_conn_id').host }}`` or
Review comment:
Is this a good example? If `my_conn_id` exists this is the same as
`conn.my_conn_id`, and if it does not the `.host` part results in an error.
##########
File path: docs/apache-airflow/concepts/connections.rst
##########
@@ -24,9 +24,11 @@ A Connection is essentially set of parameters - such as
username, password and h
They can be managed via the UI or via the CLI; see :doc:`/howto/connection`
for more information on creating, editing and managing connections. There are
customizable connection storage and backend options.
-You can use Connections directly from your own code, or you can use them via
Hooks.
+You can use Connections directly from your own code, you can use them via
Hooks or use them from :ref:`templates <concepts:jinja-templating>`::
+ echo {{ conn.<variable_name>.host }}
Review comment:
`connection_id`?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]