Change Password

Please enter the password.
Please enter the password. Between 8-64 characters. Not identical to your email address. Contain at least 3 of: uppercase, lowercase, numbers, and special characters.
Please enter the password.
Submit

Change Nickname

Current Nickname:
Submit

Apply New License

License Detail

Please complete this required field.

  • Ultipa Graph V4

Standalone

Please complete this required field.

Please complete this required field.

The MAC address of the server you want to deploy.

Please complete this required field.

Please complete this required field.

Cancel
Apply
ID
Product
Status
Cores
Applied Validity Period(days)
Effective Date
Excpired Date
Mac Address
Apply Comment
Review Comment
Close
Profile
  • Full Name:
  • Phone:
  • Company:
  • Company Email:
  • Country:
  • Language:
Change Password
Apply

You have no license application record.

Apply
Certificate Issued at Valid until Serial No. File
Serial No. Valid until File

Not having one? Apply now! >>>

Product Created On ID Amount (USD) Invoice
Product Created On ID Amount (USD) Invoice

No Invoice

v5.0
Search
    English
    v5.0

      Graphset Management

      This section introduces methods on a Connection object for managing graphsets in the database.

      Each example focuses solely on the method's usage. For a complete code example, please refer to the full example.

      showGraph()

      Retrieves all graphsets from the database.

      Parameters:

      • RequestConfig (Optional): Configuration settings for the request.

      Returns:

      • ResponseListGraph: The list of all graphsets in the database.

      # Retrieves all graphsets and prints the names of the those who have over 2000 edges
      
      graphs = Conn.showGraph().data
      for graph in graphs:
          if graph.totalEdges > 2000:
              print(graph.name)
      

      Display_Ad_Click
      ERP_DATA2
      wikiKG
      

      getGraph()

      Retrieves one graphset from the database by its name.

      Parameters:

      • str: Name of the graphset.
      • RequestConfig (Optional): Configuration settings for the request.

      Returns:

      • ResponseGraph: The retrieved graphset.

      # Retrieves the graphsets named 'wikiKG' and prints all its information
      
      graph = Conn.getGraph("wikiKG")
      print(graph.toJSON())
      

      {"description": "", "id": "13844", "name": "wikiKG", "status": "MOUNTED", "totalEdges": "167799", "totalNodes": "44449"}
      

      createGraph()

      Creates a new graphset in the database.

      Parameters:

      • GraphSet: The graphset to be created; the field name must be set, description is optional.
      • RequestConfig (Optional): Configuration settings for the request.

      Returns:

      • UltipaResponse: Result of the request.

      # Creates one graphset and prints the error code
      
      graph = GraphSet(
          name="testPythonSDK",
          description="testPythonSDK desc"
      )
      response = Conn.createGraph(graph)
      print(response.status.code)
      

      A new graphset testPythonSDK is created in the database, and the driver prints:

      0
      

      createGraphIfNotExist()

      Creates a new graphset in the database, handling cases where the given graphset name already exists by ignoring the error.

      Parameters:

      • GraphSet: The graphset to be created; the field name must be set, description is optional.
      • RequestConfig (Optional): Configuration settings for the request.

      Returns:

      • bool: Whether the graph already exists.
      • UltipaResponse or None: Result of the request; returns None if the graph already exists.

      # Creates one graphset and prints the error code
      
      graph = GraphSet(
          name="testPythonSDK",
          description="testPythonSDK desc"
      )
      
      response1 = Conn.createGraphIfNotExist(graph)
      if response1[0] is False:
          print("Code =", response1[1].status.code)
      else:
          print("No response")
      
      # Attempts to create the same graphset again and prints the error code
      
      response2 = Conn.createGraphIfNotExist(graph)
      if response2[0] is False:
          print("Code =", response2[1].status.code)
      else:
          print("No response")
      

      A new graphset testPythonSDK is created in the database, and the driver prints:

      Code = 0
      No response
      

      dropGraph()

      Drops one graphset from the database by its name.

      Parameters:

      • str: Name of the graphset.
      • RequestConfig (Optional): Configuration settings for the request.

      Returns:

      • UltipaResponse: Result of the request.

      # Creates one graphset and then drops it, prints the result
      
      graph = GraphSet(
          name="testPythonSDK",
          description="testPythonSDK desc"
      )
      
      response1 = Conn.createGraph(graph)
      print(response1.status.code)
      
      response2 = Conn.dropGraph("testPythonSDK")
      print(response2.status.code)
      

      0
      0
      

      alterGraph()

      Alters the name and description of one existing graphset in the database by its name.

      Parameters:

      • GraphSet: The existing graphset to be altered; the field name must be set.
      • GraphSet: The new configuration for the existing graphset; either or both of the fields name and description must be set.
      • RequestConfig (Optional): Configuration settings for the request.

      Returns:

      • UltipaResponse: Result of the request.

      # Renames the graphset 'testPythonSDK' to 'newGraph', sets a description for it, and prints the result
      
      oldGraph = GraphSet('testPythonSDK')
      newGraph = GraphSet(name='newGraph1', description="a new graph")
      
      response = Conn.alterGraph(oldGraph, newGraph)
      print(response.status.code)
      

      0
      

      truncate()

      Truncates (Deletes) the specified nodes or edges in the given graphset or truncates the entire graphset. Note that truncating nodes will cause the deletion of edges attached to those affected nodes. The truncating operation retains the definition of schemas and properties while deleting the data.

      Parameters:

      • Truncate: The object to truncate; the field graphName must be set, dbType and schema are optional, but schema cannot be set without the setting of dbType.
      • RequestConfig (Optional): Configuration settings for the request.

      Returns:

      • UltipaResponse: Result of the request.

      # Truncates @person nodes in the graphset 'exKG' and prints the error code
      
      target1 = Truncate(graphName="exKG", schema="person", dbType=DBType.DBNODE)
      response1 = Conn.truncate(target1)
      print(response1.status.code)
      
      # Truncates all edges in the graphset 'exKG' and prints the error code	
      
      target2 = Truncate(graphName="exKG", schema="*", dbType=DBType.DBEDGE)
      response2 = Conn.truncate(target2)
      print(response2.status.code)
      
      # Truncates the graphset 'exKG' and prints the error code
      
      target3 = Truncate(graphName="exKG")
      response3 = Conn.truncate(target3)
      print(response3.status.code)
      

      0
      0
      0
      

      compact()

      Compacts a graphset by clearing its invalid and redundant data on the server disk. Valid data will not be affected.

      Parameters:

      • str: Name of the graphset.
      • RequestConfig (Optional): Configuration settings for the request.

      Returns:

      • UltipaResponse: Result of the request.

      # Compacts the graphset 'miniCircle' and prints the error code
      
      response = Conn.compact("miniCircle")
      print(response.status.code)
      

      0
      

      hasGraph()

      Checks the existence of a graphset in the database by its name.

      Parameters:

      • str: Name of the graphset.
      • RequestConfig (Optional): Configuration settings for the request.

      Returns:

      • bool: Result of the request.

      # Checks the existence of graphset 'miniCircle' and prints the result
      
      response = Conn.hasGraph("miniCircle")
      print(response)
      

      True
      

      unmountGraph()

      Unmounts a graphset to save database memory.

      Parameters:

      • str: Name of the graphset.
      • RequestConfig (Optional): Configuration settings for the request.

      Returns:

      • UltipaResponse: Result of the request.

      # Unmounts the graphsets 'miniCircle' and prints its status
      
      Conn.unmountGraph("miniCircle")
      
      time.sleep(2)
      graph = Conn.getGraph("miniCircle")
      print(graph.data.status)
      

      UNMOUNTED
      

      mountGraph()

      Mounts a graphset to the database memory.

      Parameters:

      • str: Name of the graphset.
      • RequestConfig (Optional): Configuration settings for the request.

      Returns:

      • UltipaResponse: Result of the request.

      # Mounts the graphsets 'miniCircle' and prints its status
      
      Conn.mountGraph("miniCircle")
      
      time.sleep(2)
      graph = Conn.getGraph("miniCircle")
      print(graph.data.status)
      

      MOUNTED
      

      Full Example

      from ultipa import Connection, UltipaConfig, Truncate
      
      ultipaConfig = UltipaConfig()
      # URI example: ultipaConfig.hosts = ["mqj4zouys.us-east-1.cloud.ultipa.com:60010"]
      ultipaConfig.hosts = ["192.168.1.85:60061", "192.168.1.87:60061", "192.168.1.88:60061"]
      ultipaConfig.username = "<username>"
      ultipaConfig.password = "<password>"
      
      Conn = Connection.NewConnection(defaultConfig=ultipaConfig)
      
      target = Truncate(graphName="exKG")
      response = Conn.truncate(target)
      print(response.status.code)
      
      Please complete the following information to download this book
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写