删除操作

6.1 删除点

  • Connection 对象提供了 deleteNode方法进行删除点,支持以Filter方式或指定ID进行匹配删除。

  • 通过 id 进行删除

    from ultipa import Connection,ULTIPA_REQUEST
    conn = Connection(host='host:port', username="root", password="root")
    ret = conn.deleteNode(ULTIPA_REQUEST.DeleteNode(id=3))
    print(ret.toJSON())
    
  • 通过 filter 进行删除(了解更多信息请查看Ultipa UQL指南文档)

    from ultipa import Connection,ULTIPA_REQUEST,FILTER
    conn = Connection(host='host:port', username="root", password="root")
    ufilter = FILTER.EqFilter(name='age', value=20)
    ret = conn.deleteNode(ULTIPA_REQUEST.DeleteNode(filter=ufilter))
    print(ret.toJSON())
    

6.2 删除边

  • Connection 对象提供了 deleteNode方法进行删除点,支持以Filter方式或指定ID进行匹配删除。

  • 通过 id 进行删除

    from ultipa import Connection,ULTIPA_REQUEST
    conn = Connection(host='host:port', username="root", password="root")
    ret = conn.deleteEdge(ULTIPA_REQUEST.DeleteEdge(id=3))
    print(ret.toJSON())
    
  • 通过 filter 进行删除(了解更多信息请查看Ultipa UQL指南文档)

    from ultipa import Connection,ULTIPA_REQUEST,FILTER
    conn = Connection(host='host:port', username="root", password="root")
    ufilter = FILTER.EqFilter(name='rank', value=12)
    ret = conn.deleteEdge(ULTIPA_REQUEST.DeleteEdge(filter=ufilter))
    print(ret.toJSON())
    

6.3 清除数据

  • Connection 对象提供了 truncate 方法进行清除点、边、或者所有数据。
  • 清除点数据
    from ultipa import Connection,ULTIPA_REQUEST
    conn = Connection(host='host:port', username="root", password="root")
    ret = conn.truncate(request=ULTIPA_REQUEST.Truncate(ULTIPA.TruncateType.NODE))
    print(ret.toJSON())
    
  • 清除边数据
    from ultipa import Connection,ULTIPA_REQUEST
    conn = Connection(host='host:port', username="root", password="root")
    ret = conn.truncate(request=ULTIPA_REQUEST.Truncate(ULTIPA.TruncateType.EDGE))
    print(ret.toJSON())
    
  • 清除所有数据
    from ultipa import Connection,ULTIPA_REQUEST
    conn = Connection(host='host:port', username="root", password="root")
    ret = conn.truncate(request=ULTIPA_REQUEST.Truncate(all=True))
    print(ret.toJSON())