sunank200 commented on code in PR #52297:
URL: https://github.com/apache/airflow/pull/52297#discussion_r2182306509


##########
airflow-core/docs/public-airflow-interface.rst:
##########
@@ -151,33 +249,58 @@ by extending them:
   _api/airflow/hooks/index
 
 Public Airflow utilities
-------------------------
+========================
 
-When writing or extending Hooks and Operators, DAG authors and developers can
+When writing or extending Hooks and Operators, DAG Authors and developers can
 use the following classes:
 
-* The :class:`~airflow.models.connection.Connection`, which provides access to 
external service credentials and configuration.
-* The :class:`~airflow.models.variable.Variable`, which provides access to 
Airflow configuration variables.
-* The :class:`~airflow.models.xcom.XCom` which are used to access to 
inter-task communication data.
+* The :class:`~airflow.sdk.Connection`, which provides access to external 
service credentials and configuration.
+* The :class:`~airflow.sdk.Variable`, which provides access to Airflow 
configuration variables.
+* The :class:`~airflow.sdk.execution_time.xcom.XCom` which are used to access 
to inter-task communication data.
+
+Connection and Variable operations should be performed through the Task 
Context using
+:func:`~airflow.sdk.get_current_context` and the task instance's methods, or 
through the airflow.sdk namespace.
+Direct database access to :class:`~airflow.models.connection.Connection` and 
:class:`~airflow.models.variable.Variable`
+models is no longer allowed from task code.
+
+Example of accessing connections and variables through Task Context:
+
+.. code-block:: python
+
+    from airflow.sdk import get_current_context
+
+
+    def my_task():
+        context = get_current_context()
+
+        conn = context["conn"]
+        my_connection = conn.get_connection("my_connection_id")
+
+        var = context["var"]
+        my_variable = var.get("my_variable_name")

Review Comment:
   Changed it.



-- 
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]

Reply via email to