graphcast.db.util
¶
Database cursor utilities for graph operations.
This module provides utility functions for working with database cursors, particularly for handling batch data retrieval and cursor iteration.
Key Functions
- get_data_from_cursor: Retrieve data from a cursor with optional limit
Example
cursor = db.execute("FOR doc IN collection RETURN doc") batch = get_data_from_cursor(cursor, limit=100)
get_data_from_cursor(cursor, limit=None)
¶
Retrieve data from a cursor with optional limit.
This function iterates over a database cursor and collects the results into a batch. It handles cursor iteration errors and supports an optional limit on the number of items retrieved.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cursor
|
Database cursor to iterate over |
required | |
limit
|
Optional maximum number of items to retrieve |
None
|
Returns:
Name | Type | Description |
---|---|---|
list |
Batch of items retrieved from the cursor |
Note
The function will stop iteration if: - The limit is reached - The cursor is exhausted - A CursorNextError occurs