function get_all_dbo_establishmentcycles
Retrieves all nodes of type dbo_EstablishmentCycles from a Neo4j graph database with a configurable limit on the number of results returned.
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
763 - 770
simple
Purpose
This function queries a Neo4j graph database to fetch dbo_EstablishmentCycles nodes. It's designed for retrieving establishment cycle data from a knowledge graph, likely representing business or organizational lifecycle information. The function uses a parameterized query to allow flexible result limiting, making it suitable for pagination or controlled data retrieval scenarios.
Source Code
def get_all_dbo_establishmentcycles(limit=100):
"""Return dbo_EstablishmentCycles nodes (limited to 25)"""
query = """
MATCH (n:dbo_EstablishmentCycles)
RETURN n
LIMIT $limit
"""
return run_query(query, {"limit": limit})
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
limit |
- | 100 | positional_or_keyword |
Parameter Details
limit: Integer value that controls the maximum number of dbo_EstablishmentCycles nodes to return from the database. Default is 100, though the docstring incorrectly states 25. Must be a positive integer. Higher values may impact query performance.
Return Value
Returns the result of run_query() function, which typically returns a list of Neo4j node records or a result object containing the matched dbo_EstablishmentCycles nodes. The exact return type depends on the implementation of run_query(), but it likely returns a list of dictionaries or Neo4j Record objects, each representing a node with its properties. Returns an empty collection if no nodes match or if limit is 0.
Dependencies
neo4j
Required Imports
from neo4j import GraphDatabase
Usage Example
# Assuming run_query is defined and Neo4j connection is configured
from neo4j import GraphDatabase
# Get default 100 establishment cycles
results = get_all_dbo_establishmentcycles()
for record in results:
print(record['n'])
# Get only 10 establishment cycles
limited_results = get_all_dbo_establishmentcycles(limit=10)
# Get all establishment cycles (use with caution on large datasets)
all_results = get_all_dbo_establishmentcycles(limit=10000)
Best Practices
- Note the discrepancy: the docstring says 'limited to 25' but the default parameter is 100. Update documentation to match implementation.
- Be cautious with the limit parameter on large databases - very high limits may cause performance issues or memory problems.
- Ensure the run_query() function properly handles database connections and error cases.
- Consider adding error handling for invalid limit values (negative numbers, non-integers).
- For production use, consider adding pagination support (SKIP clause) rather than just LIMIT.
- Verify that the Neo4j database connection is properly closed after query execution to prevent resource leaks.
- Consider adding type hints to the function signature for better code documentation and IDE support.
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_all_dbo_establishment 87.9% similar
-
function get_dbo_establishmentcycles_with_references_establishment_dbo_establishment 86.5% similar
-
function get_dbo_establishmentcycles_by_id 85.4% similar
-
function get_dbo_establishmentcycles_by_uid 79.5% similar
-
function create_dbo_establishmentcycles 75.0% similar