Documentation
Data Ingestion
Neo4j Connector

Module: neo4j_connector.py

Class and Functions

Neo4jConnector

class Neo4jConnector:
    """
    Neo4jConnector facilitates connecting to a Neo4j database and executing queries.
    """
 
 
def __init__(self, uri, user, password):
    """
    Initializes the Neo4jConnector with connection credentials.
 
    Parameters:
        uri (str): The connection URI for the Neo4j database.
        user (str): The username for authentication.
        password (str): The password for authentication.
    """
 
 
def close(self):
    """
    Closes the database connection.
    """
 
 
def add_node(self, label, properties):
    """
    Adds a node to the graph.
 
    Parameters:
        label (str): The label of the node.
        properties (dict): A dictionary of properties for the node.
    """
 
 
def add_relationship(self, rel_type: str, from_id: int, to_id: int):
    """
    Creates a relationship between two nodes.
 
    Parameters:
        from_id (int): The id that identify the starting node.
        rel_type (str): The type of relationship.
        to_id (int): The id that identify the ending node.
    """
 
 
def execute_query(self, query, parameters=None):
    """
    Executes a custom Cypher query.
 
    Parameters:
        query (str): The Cypher query to execute.
        parameters (dict, optional): A dictionary of parameters for the query.
 
    Returns:
        list: A list of records returned by the query.
    """