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 2020/01/01 13:28:44 UTC

[GitHub] [airflow] eladkal commented on a change in pull request #6604: [AIRFLOW-5920] Neo4j operator and hook

eladkal commented on a change in pull request #6604: [AIRFLOW-5920] Neo4j operator and hook
URL: https://github.com/apache/airflow/pull/6604#discussion_r362323231
 
 

 ##########
 File path: airflow/providers/neo4j/example_dags/example_neo4j_operator.py
 ##########
 @@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+#
+# 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.
+#
+"""
+Code that goes along with the Airflow located at:
+http://airflow.readthedocs.org/en/latest/tutorial.html
+"""
+from datetime import datetime, timedelta
+
+from airflow import DAG
+from airflow.providers.neo4j.operators.neo4j_operator import Neo4JOperator
+
+default_args = {
+    "owner": "airflow",
+    "depends_on_past": True,
+    "start_date": datetime(2015, 6, 1),
+    "email": ["airflow@airflow.com"],
+    "email_on_failure": False,
+    "email_on_retry": False,
+    "retries": 1,
+    "retry_delay": timedelta(minutes=5),
+}
+
+with DAG(
+    'neo4j_example',
+    default_args=default_args,
+    schedule_interval='@once'
+) as dag:
+
+    # [START howto_operator_neo4j]
+    t1 = Neo4JOperator(
+        task_id="RunNeo4JQueryFixed",
+        cypher_query="MATCH (n) RETURN id(n)",
+        output_filename="myfile.csv",
+        soft_fail=True,
+        n4j_conn_id="ExampleN4J",
+        dag=dag
+    )
+    # [END howto_operator_neo4j]
+
+    # [START howto_operator_neo4j_from_file]
+    t2 = Neo4JOperator(
+        task_id="RunNeo4JQueryFromFile",
+        cypher_query="input.cypher",
+        output_filename="output.csv",
+        soft_fail=True,
+        n4j_conn_id="ExampleN4J",
 
 Review comment:
   I wonder if this actually explain what is needed.
   Only if you will look in the test code you will see that the conn type is `jdbc` and how to define it:
   ```
               Connection(
                   conn_id='mock_config',
                   conn_type='jdbc',
                   host='localhost',
                   port=1234,
                   login='your_name_here',
                   password='your_token_here'
               )
   ```
   
   I think it should have its own connection available to define in the UI like other DB connections.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services