# Neo4j Tasks


This module contains a collection of tasks to interact with Neo4j.

# Neo4jRunCypherQueryTask

class

prefect.tasks.neo4j.neo4j_tasks.Neo4jRunCypherQueryTask

(server_uri=None, user=None, password=None, db_name=None, server_uri_env_var=None, user_env_var=None, password_env_var=None, db_name_env_var=None, cypher_query=None, return_result_as="raw", **kwargs)[source]

Task to run a Cypher query against Neo4j. More information about the Cypher query language, can be found at https://neo4j.com/developer/cypher/. This task uses py2neo under the hood. For more information, please visit https://py2neo.org/2021.1/index.html.

Args:

  • server_uri (str, optional): The Neo4j URI to connect to. More information regarding the accepted forms for server_uri can be found at https://py2neo.org/2021.1/profiles.html. This parameter, if provided, takes precedence over server_uri_env_var.
  • user (str, optional): The user to use to connect to Neo4j. This parameter, if provided, takes precedence over user_env_var.
  • password (str, optional): The password to use to connect to Neo4j. This parameter, if provided, takes precedence over password_env_var.
  • db_name: (str, optional): The database name where the Cypher query will run. This parameter, if provided, takes precedence over db_name_env_var.
  • server_uri_env_var (str, optional): The name of the environment variable that contains the Neo4j server URI to connect to.
  • user_env_var (str, optional): The name of the environment variable that contains the user to use to connect to Neo4j.
  • password_env_var (str, optional): The name of the environment variable that contains the password to use to connect to Neo4j.
  • db_name_env_var (str, optional): The name of the environment variable that contains the database name where the Cypher query will run.
  • cypher_query (str, optional): The Cypher query to run. More information about the Cypher query language, can be found at https://neo4j.com/developer/cypher/.
  • return_result_as (str, optional): How to return the result. Accepted values are raw, dataframe. Defaults to raw (which will return a list of dict). Applies only when the query returned result is not empty.
  • **kwargs (dict, optional): Additional keyword arguments to pass to the Task constructor.

methods:                                                                                                                                                       

prefect.tasks.neo4j.neo4j_tasks.Neo4jRunCypherQueryTask.run

(server_uri=None, user=None, password=None, db_name=None, server_uri_env_var=None, user_env_var=None, password_env_var=None, db_name_env_var=None, cypher_query=None, return_result_as="raw")[source]

Task run method to run a Cypher query against Neo4j.

Args:

  • server_uri (str, optional): The Neo4j URI to connect to. More information regarding the accepted forms for server_uri can be found at https://py2neo.org/2021.1/profiles.html. This parameter, if provided, takes precedence over server_uri_env_var.
  • user (str, optional): The user to use to connect to Neo4j. This parameter, if provided, takes precedence over user_env_var.
  • password (str, optional): The password to use to connect to Neo4j. This parameter, if provided, takes precedence over password_env_var.
  • db_name: (str, optional): The database name where the Cypher query will run. This parameter, if provided, takes precedence over db_name_env_var.
  • server_uri_env_var (str, optional): The name of the environment variable that contains the Neo4j server URI to connect to.
  • user_env_var (str, optional): The name of the environment variable that contains the user to use to connect to Neo4j.
  • password_env_var (str, optional): The name of the environment variable that contains the password to use to connect to Neo4j.
  • db_name_env_var (str, optional): The name of the environment variable that contains the database name where the Cypher query will run.
  • cypher_query (str, optional): The Cypher query to run. More information about the Cypher query language, can be found at https://neo4j.com/developer/cypher/.
  • return_result_as (str, optional): How to return the result. Accepted values are raw, dataframe. Defaults to raw (which will return a list of dict). Applies only when the query returned result is not empty.
Returns:
  • None if the query result is empty. - The original result if return_result_as is raw. - A pandas.DataFrame if return_result_as is dataframe.
Raises:
  • ValueError if both server_uri and server_uri_env_var are None. - ValueError if server_uri is None and server_uri_env_var is not found. - ValueError if both user and user_env_var are None. - ValueError if user is None and user_env_var is not found. - ValueError if both password and password_env_var are not found. - ValueError if password is None and password_env_var is not found. - ValueError if db_name is None and db_name_env_var is not found. - ValueError if cypher_query is None. - ValueError if return_result_as is not one of raw, dataframe. - prefect.engine.signals.FAIL if any error occurs while establishing the connection with Neo4j. - prefect.engine.signals.FAIL if any error occurs while running the Cypher query.



This documentation was auto-generated from commit bd9182e
on July 31, 2024 at 18:02 UTC