You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/11/14 12:23:42 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #19470: Add how-to Guide for MSSQL operators

uranusjr commented on a change in pull request #19470:
URL: https://github.com/apache/airflow/pull/19470#discussion_r748846716



##########
File path: docs/apache-airflow-providers-microsoft-mssql/operators.rst
##########
@@ -0,0 +1,112 @@
+ .. Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+ ..   http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+How-to Guide for MsSqlOperator
+=================================
+
+.. _howto/operator:MsSqlOperator:
+
+Introduction
+------------
+The purpose of MSSQL Operator is to define tasks involving interactions with the MSSQL database.
+
+Use the :class:`~airflow.providers.microsoft.mssql.operators.mssql.MsSqlOperator` to execute
+SQL commands in MSSQL database.
+
+Common Database Operations with MsSqlOperator
+------------------------------------------------
+
+To use the mssql operator to carry out SQL request, two parameters are required: ``sql`` and ``mssql_conn_id``.
+These two parameters are eventually fed to the MSSQL hook object that interacts directly with the MSSQL database.
+
+Creating a MSSQL database table
+----------------------------------
+
+The code snippets below are based on Airflow-2.2
+
+An example usage of the MsSqlOperator is as follows:
+
+.. exampleinclude:: /../../airflow/providers/microsoft/mssql/example_dags/example_mssql.py
+    :language: python
+    :start-after: [START howto_operator_mssql]
+    :end-before: [END howto_operator_mssql]
+
+You can also use an external file to execute the SQL commands. Script folder must be at the same level as DAG.py file.
+This way you can easily maintain the SQL queries separated from the code.
+
+.. exampleinclude:: /../../airflow/providers/microsoft/mssql/example_dags/example_mssql.py
+    :language: python
+    :start-after: [START mssql_operator_howto_guide_create_table_mssql_from_external_file]
+    :end-before: [END mssql_operator_howto_guide_create_table_mssql_from_external_file]
+
+
+Your ``dags/create_table.sql`` should look like this:
+
+::

Review comment:
       ```suggestion
   .. code-block::sql
   ```
   
   for syntax highlighting

##########
File path: docs/apache-airflow-providers-microsoft-mssql/connections/mssql.rst
##########
@@ -0,0 +1,54 @@
+ .. Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+ ..   http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+
+
+.. _howto/connection:mssql:
+
+MSSQL Connection
+======================
+The MSSQL connection type enables connection to `MSSQL <https://www.microsoft.com/en-in/sql-server/>`__.
+
+Default Connection IDs
+----------------------
+
+MSSQL Hook uses parameter ``mssql_conn_id`` for Connection IDs and the value of the parameter
+as ``mssql_default`` by default.

Review comment:
       ```suggestion
   MSSQL Hook uses parameter ``mssql_conn_id`` for the Connection ID. The default value
   is ``mssql_default``.
   ```

##########
File path: docs/apache-airflow-providers-microsoft-mssql/connections/mssql.rst
##########
@@ -0,0 +1,54 @@
+ .. Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+ ..   http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+
+
+.. _howto/connection:mssql:
+
+MSSQL Connection
+======================
+The MSSQL connection type enables connection to `MSSQL <https://www.microsoft.com/en-in/sql-server/>`__.

Review comment:
       Maybe we should use the “official” name here, i.e. Microsoft SQL Server.




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org