修改密码

请输入密码
请输入密码 请输入8-64长度密码 和 email 地址不相同 至少包括数字、大写字母、小写字母、半角符号中的 3 个
请输入密码
提交

修改昵称

当前昵称:
提交

申请证书

证书详情

Please complete this required field.

  • Ultipa Graph V4

Standalone

Please complete this required field.

Please complete this required field.

服务器的MAC地址

Please complete this required field.

Please complete this required field.

取消
申请
ID
产品
状态
核数
申请天数
审批时间
过期时间
MAC地址
申请理由
审核信息
关闭
基础信息
  • 用户昵称:
  • 手机号:
  • 公司名称:
  • 公司邮箱:
  • 地区:
  • 语言:
修改密码
申请证书

当前未申请证书.

申请证书
Certificate Issued at Valid until Serial No. File
Serial No. Valid until File

Not having one? Apply now! >>>

ProductName CreateTime ID Price File
ProductName CreateTime ID Price File

No Invoice

v5.0
搜索
    v5.0

      图管理

      本节介绍用于管理数据库中图的方法。

      showGraph()

      从数据库获取全部图。

      参数

      • config: RequestConfig(可选):请求配置。

      返回值

      • List[GraphSet]:获取的数据库全部图列表。

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

      Display_Ad_Click
      ERP_DATA2
      wikiKG
      

      getGraph()

      从数据库获取一个指定的图。

      参数

      • graphName: str:图名称。
      • config: RequestConfig(可选):请求配置。

      返回值

      • GraphSet:获取的图。

      # Retrieves the graph named 'miniCircle'
      
      graph = Conn.getGraph("miniCircle")
      print(graph.toJSON())
      

      {"id": "444", "name": "miniCircle", "totalNodes": 304, "totalEdges": 1961, "shards": ["1"], "partitionBy": "CityHash64", "status": "NORMAL", "description": "", "slotNum": 256}
      

      hasGraph()

      检查数据库中是否存在一个指定的图。

      参数

      • graphName: str:图名称。
      • config: RequestConfig(可选):请求配置。

      返回值

      • bool:检查结果。

      # Checks the existence of a graph named 'miniCircle'
      
      response = Conn.hasGraph("miniCircle")
      print(response)
      

      True
      

      createGraph()

      在数据库中创建一个图。

      参数

      • graphSet: GraphSet:待创建的图;name字段必填,shardspartitionBydescription可选。
      • config: RequestConfig(可选):请求配置。

      返回值

      • Response:请求结果。

      # Creates a graph
      
      graph = GraphSet(
          name="testPythonSDK",
          shards=[1],
          partitionBy="Crc32",
          description="testPythonSDK desc"
      )
      response = Conn.createGraph(graph)
      print(response.status.code)
      

      SUCCESS
      

      createGraphIfNotExist()

      在数据库中创建一个图,并返回是否数据库中已有同名图存在。

      参数

      • graphSet: GraphSet:待创建的图;name字段必填,shardspartitionBydescription可选。
      • config: RequestConfig(可选):请求配置。

      返回值

      • Dict[bool, Response]: 图集是否存在,以及请求结果

      graph = GraphSet(
          name="testPythonSDK",
          shards=[1],
          partitionBy="Crc32",
          description="testPythonSDK desc"
      )
      
      result = Conn.createGraphIfNotExist(graph)
      boolValue = result.get('exist')
      response = result.get('response')
      
      print("Does the graph already exist?", boolValue)
      if response.status is None:
          print("Graph creation status: No response")
      else:
          print("Graph creation status:", response.status.code)
      
      print("----- Creates the graph again -----")
      
      result_1 = Conn.createGraphIfNotExist(graph)
      boolValue_1 = result_1.get('exist')
      response_1 = result_1.get('response')
      
      print("Does the graph already exist?", boolValue_1)
      if response_1.status is None:
          print("Graph creation status: No response")
      else:
          print("Graph creation status:", response_1.status.code)
      

      Does the graph already exist? False
      Graph creation status: SUCCESS
      ----- Creates the graph again -----
      Does the graph already exist? True
      Graph creation status: No response
      

      dropGraph()

      从数据库中删除一个指定的图。

      参数

      • graphName: str:图名称。
      • config: RequestConfig(可选):请求配置。

      返回值

      • Response:请求结果。

      # Creates a graph and then drops it
      
      graph = GraphSet(
          name="testPythonSDK",
          shards=[1],
          partitionBy="Crc32",
          description="testPythonSDK desc"
      )
      
      response1 = Conn.createGraph(graph)
      print("Graph creation:", response1.status.code)
      
      response2 = Conn.dropGraph("testPythonSDK")
      print("Graph deletion:", response2.status.code)
      

      Graph creation: SUCCESS
      Graph deletion: SUCCESS
      

      alterGraph()

      修改数据库中一个图的名称和描述。

      参数

      • graphName: str:图名称。
      • alterGraphset: GraphSet:用于设置新的图name和/或descriptionGraphSet对象。
      • config: RequestConfig(可选):请求配置。

      返回值

      • Response:请求结果。

      # Alters the name and description of the graph 'testPythonSDK'
      
      newGraphInfo = GraphSet(name='newGraph', description="a new graph")
      response = Conn.alterGraph("testPythonSDK", newGraphInfo)
      print(response.status.code)
      

      SUCCESS
      

      truncate()

      清空(删除)图中的指定点或边,或清空整个图。请注意,清空点的同时会删除与点相连的所有边。清空操作仅删除点边,图的schema和属性定义仍保留。

      参数

      • request: TruncateParams:清空操作的参数;graphName字段必填,schemaNamedbType可选但必须同时设置。
      • config: RequestConfig(可选):请求配置。

      返回值

      • Response:请求结果。

      # Truncates User nodes in 'myGraph'
      
      param1 = TruncateParams(graphName="myGraph", schemaName="User", dbType=DBType.DBNODE)
      response1 = Conn.truncate(param1)
      print(response1.status.code)
      
      # Truncates all edges in the 'myGraph'
      
      param2 = TruncateParams(graphName="myGraph", schemaName="*", dbType=DBType.DBEDGE)
      response2 = Conn.truncate(param2)
      print(response2.status.code)
      
      # Truncates 'myGraph'
      
      param3 = TruncateParams(graphName="myGraph")
      response3 = Conn.truncate(param3)
      print(response3.status.code)
      

      SUCCESS
      SUCCESS
      SUCCESS
      

      compact()

      清除图中的无效及冗余数据。有效数据不会受到影响。

      参数

      • graphName: str:图名称。
      • config: RequestConfig(可选):请求配置。

      返回值

      • Response:请求结果。

      # Compacts the graph 'miniCircle'
      
      response = Conn.compact("miniCircle")
      print(response.status.code)
      

      SUCCESS
      

      完整示例

      from ultipa import UltipaConfig, Connection, GraphSet
      
      ultipaConfig = UltipaConfig()
      # URI example: ultipaConfig.hosts = ["https://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)
      
      # Creates a graph
      
      graph = GraphSet(
          name="testPythonSDK",
          shards=[1],
          partitionBy="Crc32",
          description="testPythonSDK desc"
      )
      response = Conn.createGraph(graph)
      print(response.status.code)
      
      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写