function get_all_lims_testparameters
Retrieves LIMS_Testparameters nodes from a Neo4j graph database with a configurable limit on the number of results returned.
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
412 - 419
simple
Purpose
This function queries a Neo4j database to fetch all nodes labeled as LIMS_Testparameters, which likely represent test parameters in a Laboratory Information Management System (LIMS). It's designed for retrieving test parameter configurations or metadata stored in a graph database, with a default limit to prevent overwhelming result sets. The function uses Cypher query language to match and return nodes.
Source Code
def get_all_lims_testparameters(limit=100):
"""Return LIMS_Testparameters nodes (limited to 25)"""
query = """
MATCH (n:LIMS_Testparameters)
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 LIMS_Testparameters nodes to return from the database. Default is 100. Note: The docstring incorrectly states 'limited to 25', but the actual default is 100. This parameter helps manage query performance and result set size.
Return Value
Returns the result of run_query() function execution. The exact return type depends on the run_query implementation, but typically would be a list of Neo4j node records or a result object containing LIMS_Testparameters nodes. Each node would contain properties associated with test parameters in the LIMS system. If no nodes match, an empty result set is returned.
Dependencies
neo4j
Required Imports
from neo4j import GraphDatabase
Usage Example
# Assuming run_query is defined and Neo4j connection is configured
# Example 1: Get default 100 test parameters
results = get_all_lims_testparameters()
for record in results:
node = record['n']
print(node)
# Example 2: Get only 10 test parameters
results = get_all_lims_testparameters(limit=10)
# Example 3: Get maximum 500 test parameters
results = get_all_lims_testparameters(limit=500)
Best Practices
- Always specify an appropriate limit value based on expected data volume to avoid performance issues
- The docstring contains incorrect information (states 'limited to 25' but default is 100) - should be updated for accuracy
- Ensure the run_query() function properly handles database connection errors and returns results in a consistent format
- Consider adding error handling for database connection failures
- For production use, consider adding pagination support for large datasets instead of relying solely on LIMIT
- Validate that the limit parameter is a positive integer before passing to the query
- Consider adding type hints for better code documentation (e.g., limit: int -> List[Dict])
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_all_lims_parameters 94.1% similar
-
function get_all_lims_tests 90.4% similar
-
function get_all_lims_sampletestresults 88.4% similar
-
function get_lims_testparameters_by_id 86.6% similar
-
function get_all_lims_tests4pathogens 86.5% similar