🔍 Code Extractor

function get_dbo_houses_with_references_establishment_dbo_establishment

Maturity: 40

Queries a Neo4j graph database to retrieve dbo_Establishment nodes that are connected to a specific dbo_Houses node through a REFERENCES_ESTABLISHMENT relationship.

File:
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
Lines:
1961 - 1968
Complexity:
simple

Purpose

This function is designed to traverse a graph database relationship between houses and establishments. It's useful for finding all establishments referenced by a particular house, such as businesses, organizations, or facilities associated with a residential property. The function supports pagination through a configurable limit parameter.

Source Code

def get_dbo_houses_with_references_establishment_dbo_establishment(source_id, limit=100):
    """Get dbo_Establishment nodes connected to a dbo_Houses via REFERENCES_ESTABLISHMENT"""
    query = """
    MATCH (source:dbo_Houses {id: $source_id})-[r:REFERENCES_ESTABLISHMENT]->(target:dbo_Establishment)
    RETURN target
    LIMIT $limit
    """
    return run_query(query, {"source_id": source_id, "limit": limit})

Parameters

Name Type Default Kind
source_id - - positional_or_keyword
limit - 100 positional_or_keyword

Parameter Details

source_id: The unique identifier (id property) of the dbo_Houses node from which to start the traversal. This should be a string or integer value that matches the 'id' property of a node in the Neo4j database.

limit: Maximum number of dbo_Establishment nodes to return. Defaults to 100. This parameter controls pagination and prevents overwhelming results. Must be a positive integer.

Return Value

Returns the result of the run_query function execution, which typically contains a list or collection of dbo_Establishment nodes (target nodes) that match the query criteria. The exact return type depends on the run_query implementation, but it likely returns a list of dictionaries or Neo4j Record objects containing the properties of each matched dbo_Establishment node. Returns an empty collection if no matching establishments are found.

Dependencies

  • neo4j

Required Imports

from neo4j import GraphDatabase

Usage Example

# Assuming run_query is defined and Neo4j is configured
from neo4j import GraphDatabase

# Define or import the run_query helper function
def run_query(query, params):
    driver = GraphDatabase.driver('bolt://localhost:7687', auth=('neo4j', 'password'))
    with driver.session() as session:
        result = session.run(query, params)
        return [record['target'] for record in result]
    driver.close()

# Get establishments referenced by house with id '12345'
establishments = get_dbo_houses_with_references_establishment_dbo_establishment('12345', limit=50)

# Process results
for establishment in establishments:
    print(f"Establishment: {establishment}")

# Get all establishments (up to default limit of 100)
all_establishments = get_dbo_houses_with_references_establishment_dbo_establishment('67890')

Best Practices

  • Ensure the source_id parameter matches the exact format and type of the 'id' property in your Neo4j database
  • Use appropriate limit values to prevent performance issues with large result sets
  • Handle cases where no establishments are found (empty result set)
  • Consider implementing error handling for database connection failures
  • Validate that the run_query function properly closes database connections to prevent resource leaks
  • Consider adding indexes on the 'id' property of dbo_Houses nodes for better query performance
  • Be aware that this function depends on the run_query helper function being properly implemented and available

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_dbo_establishmentcycles_with_references_establishment_dbo_establishment 87.6% similar

    Queries a Neo4j graph database to retrieve dbo_Establishment nodes that are connected to a specific dbo_EstablishmentCycles node through a REFERENCES_ESTABLISHMENT relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_dbo_treatments_with_references_establishment_dbo_establishment 85.0% similar

    Queries a Neo4j graph database to retrieve dbo_Establishment nodes that are connected to a specific dbo_Treatments node through a REFERENCES_ESTABLISHMENT relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_dbo_tnv_with_references_establishment_dbo_establishment 84.8% similar

    Queries a Neo4j graph database to retrieve dbo_Establishment nodes that are connected to a specific dbo_TNV node through a REFERENCES_ESTABLISHMENT relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function create_references_establishment_relationship_v2 84.8% similar

    Creates a REFERENCES_ESTABLISHMENT relationship in a Neo4j graph database between a dbo_Houses node and a dbo_Establishment node, with optional properties on the relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_dbo_flocks_with_references_establishment_dbo_establishment 83.5% similar

    Queries a Neo4j graph database to retrieve dbo_Establishment nodes that are connected to a specific dbo_Flocks node through a REFERENCES_ESTABLISHMENT relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
← Back to Browse