potiuk commented on a change in pull request #4170: [AIRFLOW-3275] Implement 
Google Cloud SQL Query operator
URL: https://github.com/apache/incubator-airflow/pull/4170#discussion_r232603047
 
 

 ##########
 File path: airflow/contrib/operators/gcp_sql_operator.py
 ##########
 @@ -524,3 +524,81 @@ def execute(self, context):
         else:
             return self._hook.delete_database(self.project_id, self.instance,
                                               self.database)
+
+
+class CloudSqlQueryOperator(BaseOperator):
+    """
+    Performs DML or DDL query on an existing Cloud Sql instance. It optionally 
uses
+    cloud-sql-proxy to establish secure connection with the database.
+
+    :param sql: SQL query or list of queries to run (should be DML or DDL 
query -
+        this operator does not return any data from the database,
+        so it is useless to pass it DQL queries. Note that it is 
responsibility of the
+        author of the queries to make sure that the queries are idempotent. 
For example
+        you can use CREATE TABLE IF NOT EXISTS to create a table.
+    :type sql: str or [str]
+    :param project_id: Google Cloud Platform project where the Cloud SQL 
instance exists.
+    :type project_id: str
+    :param instance: Name of the instance of the Cloud SQL database instance.
+    :type instance: str
+    :param parameters: (optional) the parameters to render the SQL query with.
+    :type parameters: mapping or iterable
+    :param autocommit: if True, each command is automatically committed.
+        (default value: False)
+    :type autocommit: bool
+    :param database: name of database which overwrites the name defined in the 
connection
+    :type database: str
+    :param gcp_conn_id: The connection ID used to connect to Google Cloud 
Platform for
+       cloud-sql-proxy authentication.
+    :type gcp_conn_id: str
+    """
+    # [START gcp_sql_query_template_fields]
+    template_fields = ('sql', 'cloudsql_conn_id', 'gcp_conn_id')
+    template_ext = ('.sql',)
+    # [END gcp_sql_query_template_fields]
+
+    @apply_defaults
+    def __init__(self,
+                 sql,
+                 cloudsql_conn_id='google_cloud_sql_default',
 
 Review comment:
   yep.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to