function get_dbo_establishmentcycles_by_uid
Retrieves a single dbo_EstablishmentCycles node from a Neo4j graph database by matching its unique identifier (UID).
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
781 - 788
simple
Purpose
This function queries a Neo4j database to fetch a specific establishment cycle record identified by its UID. It's designed for retrieving individual establishment cycle entities from the graph database, returning the complete node if found or None if no matching node exists. This is useful for lookup operations when you need to access a specific establishment cycle's data.
Source Code
def get_dbo_establishmentcycles_by_uid(uid):
"""Get a dbo_EstablishmentCycles node by its UID"""
query = """
MATCH (n:dbo_EstablishmentCycles {UID: $uid})
RETURN n
"""
result = run_query(query, {"uid": uid})
return result[0] if result else None
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
uid |
- | - | positional_or_keyword |
Parameter Details
uid: The unique identifier (UID) of the dbo_EstablishmentCycles node to retrieve. Expected to be a string or value that matches the UID property stored in the Neo4j database. This parameter is used in the Cypher query to filter and locate the specific node.
Return Value
Returns the first matching dbo_EstablishmentCycles node as a dictionary-like object containing all properties of the node if found. Returns None if no node with the specified UID exists in the database. The return type is either a Neo4j node record (typically accessible as a dictionary) or None.
Dependencies
neo4j
Required Imports
from neo4j import GraphDatabase
Usage Example
# Assuming run_query function is defined and Neo4j connection is configured
from neo4j import GraphDatabase
# Example usage
uid_to_find = "12345-abc-def"
establishment_cycle = get_dbo_establishmentcycles_by_uid(uid_to_find)
if establishment_cycle:
print(f"Found establishment cycle: {establishment_cycle}")
# Access node properties
# print(establishment_cycle['n']['property_name'])
else:
print(f"No establishment cycle found with UID: {uid_to_find}")
Best Practices
- Ensure the run_query function is properly implemented with error handling and connection management
- Validate the uid parameter before calling this function to avoid unnecessary database queries
- Handle the None return value appropriately in calling code to avoid NoneType errors
- Consider adding type hints to the function signature for better code documentation
- Ensure proper Neo4j connection pooling and resource cleanup in the run_query implementation
- The function assumes the UID property is indexed in Neo4j for optimal query performance
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_dbo_establishmentcycles_by_id 90.6% similar
-
function get_dbo_establishment_by_uid 89.0% similar
-
function get_dbo_establishmentcycles_with_references_establishment_dbo_establishment 80.7% similar
-
function get_dbo_establishment_by_id 80.1% similar
-
function get_all_dbo_establishmentcycles 79.5% similar