模块 neug.query_result
Neug 结果模块。
QueryResult 对象
class QueryResult(object)QueryResult 表示 Cypher 查询的结果,可作为迭代器进行遍历。
它提供了以下方法用于遍历查询结果:
- hasNext():若尚有更多结果可供遍历,则返回 True。
- getNext():以列表形式返回下一个结果。
- length():返回结果的总数。
- column_names():以字符串形式返回投影列的名称。
- get_profile_metrics():返回结构化的 PROFILE 或 EXPLAIN 指标。
>>> from neug import Database
>>> db = Database("/tmp/test.db", mode="r")
>>> conn = db.connect()
>>> result = conn.execute('MATCH (n) RETURN n')
>>> for row in result:
>>> print(row)
__init__
def __init__(result)初始化 QueryResult。
- 参数:
result(PyQueryResult) 查询的结果,由查询引擎返回。它是一个 C++ 对象,并通过 pybind 导出到 Python。
column_names
def column_names()以字符串列表的形式返回投影的列名。
get_bolt_response
def get_bolt_response() -> str以 Bolt 响应格式获取结果。 TODO(zhanglei,xiaoli):确保该格式与 Neo4j Bolt 响应格式保持一致。
- 返回值:
- str 以 Bolt 响应格式表示的结果。
get_profile_metrics
def get_profile_metrics() -> dict以 Python 字典形式返回详细的 PROFILE 或 EXPLAIN 指标:
{
"total_elapsed_ms": float,
"total_output_rows": int,
"operators": [
{
"operator_id": int,
"parent_id": int,
"operator_name": str,
"elapsed_ms": float,
"output_rows": int,
"child_ids": [int],
}
],
}to_arrow
def to_arrow()将结果转换为 Arrow 表。
- 返回:
- pyarrow.Table 转换为 Arrow 表的结果。
Last updated on