UltipaDocs
Try Playground
  • Introduction
  • RESTful API
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
  1. Docs
  2. /
  3. Ultipa Drivers
  4. /
  5. Python

Result Processing

The output of the driver depends on the specific request made. Some methods, like uql(), return a UltipaResponse object, which requires you to extract the data and cast it into the corresponding driver type to serve the Python application. Other methods, like showGraph(), showSchema(), and showProperty(), return data of the driver type (GraphSet, Schema, Property, etc.) directly. Please read Types Mapping Ultipa and Python for a list of the core driver types.

UltipaResponse

The uql() and some other methods return a UltipaResponse object. UltipaResponse has the following fields:

Field
Type
Description
aliasesList[ResultAlias]List of aliases; each has name and type of the data.
itemsDictMap of aliases and their corresponding data (DataItem).
explainPlanList[ExplainPlan]Explanation tree for the UQL statement.
statusStatusExecution status of the request.
statisticsUltipaStatisticsStatistics of the request execution, including nodeAffected, edgeAffected, totalCost, engineCost, etc.
reqReturnReqRequest details, including graph_name, uql, host, Retry and uqlIsExtra.

If the query returns data, you can extract each item by its alias using the get() or alias() method. Both methods return a DataItem object, which embeds the query result. To map the DataItem to the corresponding driver type, please read Types Mapping Ultipa and Python.

get()

Retrieves data by the alias index.

Parameters:

  • int: Index of the alias.

Returns:

  • DataItem: The retrieved data.
Python
response = Conn.uql("find().nodes() as n return n._id, n._uuid limit 3")
print(response.get(0).toJSON())

The UQL statement returns two aliases n._id and n._uuid; the get() method retrieves the alias n._id at index 0.

Output
{"alias": "n._id", "data": {"name": "n._id", "type": 4, "type_desc": "ATTR", "values": ["U1", "U2", "U3"]}, "type": "ATTR"}

alias()

Retrieves data by the alias name.

Parameters:

  • str: Name of the alias.

Returns:

  • DataItem: The retrieved data.
Python
response = Conn.uql("find().nodes() as n return n._id, n._uuid limit 3")
print(response.alias('n._uuid').toJSON())

The UQL statement returns two aliases n._id and n._uuid; the alias() method retrieves the alias n._uuid by its name.

Output
{"alias": "n._uuid", "data": {"name": "n._uuid", "type": 4, "type_desc": "ATTR", "values": [1, 2, 3]}, "type": "ATTR"}