This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new e3c31752f1 Resolving mysql deprecated operator warnings (#39725)
e3c31752f1 is described below

commit e3c31752f180ae60f0c0de304793018084e02943
Author: Gopal Dirisala <39794726+dir...@users.noreply.github.com>
AuthorDate: Sun May 26 19:41:31 2024 +0530

    Resolving mysql deprecated operator warnings (#39725)
    
    * Resolving mysql deprecated operator warnings
    
    * Resolving mysql deprecated operator warnings
    
    * Resolving mysql deprecated warnings
    
    ---------
    
    Co-authored-by: Jarek Potiuk <ja...@potiuk.com>
---
 airflow/providers/mysql/operators/mysql.py        |  2 +-
 docs/apache-airflow-providers-mysql/operators.rst | 14 ++++++++------
 tests/always/test_example_dags.py                 |  1 -
 tests/system/providers/mysql/example_mysql.py     |  8 ++++----
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/airflow/providers/mysql/operators/mysql.py 
b/airflow/providers/mysql/operators/mysql.py
index ab423ef91b..2c2436b4d9 100644
--- a/airflow/providers/mysql/operators/mysql.py
+++ b/airflow/providers/mysql/operators/mysql.py
@@ -42,7 +42,7 @@ class MySqlOperator(SQLExecuteQueryOperator):
 
     .. seealso::
         For more information on how to use this operator, take a look at the 
guide:
-        :ref:`howto/operator:MySqlOperator`
+        :ref:`howto/operator:mysql`
 
     :param sql: the sql code to be executed. Can receive a str representing a
         sql statement, a list of str (sql statements), or reference to a 
template file.
diff --git a/docs/apache-airflow-providers-mysql/operators.rst 
b/docs/apache-airflow-providers-mysql/operators.rst
index 605e38fb85..2ee7b885cd 100644
--- a/docs/apache-airflow-providers-mysql/operators.rst
+++ b/docs/apache-airflow-providers-mysql/operators.rst
@@ -17,19 +17,21 @@
 
 
 
-.. _howto/operator:MySqlOperator:
+.. _howto/operator:mysql:
 
-MySqlOperator
-=============
+How-to Guide for Mysql using SQLExecuteQueryOperator
+====================================================
 
-Use the :class:`~airflow.providers.mysql.operators.MySqlOperator` to execute
+Use the 
:class:`~airflow.providers.common.sql.operators.SQLExecuteQueryOperator` to 
execute
 SQL commands in a `MySql <https://dev.mysql.com/doc/>`__ database.
 
+.. warning::
+     Previously, MySqlOperator was used to perform this kind of operation. But 
at the moment MySqlOperator is deprecated and will be removed in future 
versions of the provider. Please consider to switch to SQLExecuteQueryOperator 
as soon as possible.
 
 Using the Operator
 ^^^^^^^^^^^^^^^^^^
 
-Use the ``mysql_conn_id`` argument to connect to your MySql instance where
+Use the ``conn_id`` argument to connect to your MySql instance where
 the connection metadata is structured as follows:
 
 .. list-table:: MySql Airflow Connection Metadata
@@ -49,7 +51,7 @@ the connection metadata is structured as follows:
    * - Port: int
      - MySql port
 
-An example usage of the MySqlOperator is as follows:
+An example usage of the SQLExecuteQueryOperator is as follows:
 
 .. exampleinclude:: /../../tests/system/providers/mysql/example_mysql.py
     :language: python
diff --git a/tests/always/test_example_dags.py 
b/tests/always/test_example_dags.py
index 7d2ec685f8..d58f58d6f1 100644
--- a/tests/always/test_example_dags.py
+++ b/tests/always/test_example_dags.py
@@ -62,7 +62,6 @@ IGNORE_AIRFLOW_PROVIDER_DEPRECATION_WARNING: tuple[str, ...] 
= (
     # Deprecated Operators/Hooks, which replaced by common.sql Operators/Hooks
     "tests/system/providers/apache/drill/example_drill_dag.py",
     "tests/system/providers/microsoft/mssql/example_mssql.py",
-    "tests/system/providers/mysql/example_mysql.py",
     "tests/system/providers/snowflake/example_snowflake.py",
     "tests/system/providers/trino/example_trino.py",
 )
diff --git a/tests/system/providers/mysql/example_mysql.py 
b/tests/system/providers/mysql/example_mysql.py
index 7327d095f2..0874e24b4b 100644
--- a/tests/system/providers/mysql/example_mysql.py
+++ b/tests/system/providers/mysql/example_mysql.py
@@ -25,7 +25,7 @@ import os
 from datetime import datetime
 
 from airflow import DAG
-from airflow.providers.mysql.operators.mysql import MySqlOperator
+from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
 
 ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
 DAG_ID = "example_mysql"
@@ -33,13 +33,13 @@ DAG_ID = "example_mysql"
 with DAG(
     DAG_ID,
     start_date=datetime(2021, 1, 1),
-    default_args={"mysql_conn_id": "mysql_conn_id"},
+    default_args={"conn_id": "mysql_conn_id"},
     tags=["example"],
     catchup=False,
 ) as dag:
     # [START howto_operator_mysql]
 
-    drop_table_mysql_task = MySqlOperator(
+    drop_table_mysql_task = SQLExecuteQueryOperator(
         task_id="drop_table_mysql", sql=r"""DROP TABLE table_name;""", dag=dag
     )
 
@@ -47,7 +47,7 @@ with DAG(
 
     # [START howto_operator_mysql_external_file]
 
-    mysql_task = MySqlOperator(
+    mysql_task = SQLExecuteQueryOperator(
         task_id="drop_table_mysql_external_file",
         sql="/scripts/drop_table.sql",
         dag=dag,

Reply via email to