Graph Documentation¶
delete_graph¶
删除图。将删除图中的schema和所有数据。
函数声明
def delete_graph(self)
clear_graph¶
清空图
函数声明
def clear_graph(self)
begin_transaction¶
开启事务,事务未提交不会实际影响数据
- 使用规范
开启事务后必须用返回的事务对象进行图操作,否则事务不生效或发生异常
一个
Graph
对象可以开启多个事务并发执行事务操作完毕后,一定要主动调用
success()
或failure()
,事务默认failure()
事务实现了
AutoClosable
,不严格规定主动调用close()
函数声明
def begin_transaction(self, isolation: Union[Isolation] = None)
响应参数
Parameter |
Type |
DESC |
GraphTransaction |
事务类的实例对象 |
|
isolation |
事务隔离级别 |
示例
# 开启事务
tx = graph.begin_transaction()
# 在事务状态下添加边
tx.insert_edge_by_vertex_pk("6","个人", True, "6", "个人",True, "关注", {})
# 将事务标记为失败
tx.failure()
# tx.success()
# 关闭事务并回滚
tx.close()
# 查看事务状态
print(tx.is_open())
is_enable¶
判断 graph
对象是否可用
函数声明
def is_enable(self)
响应参数
Parameter |
Type |
DESC |
bool |
True: 图服务可用, False: 图服务不可用 |
示例
if graph.is_enable():
pass
else:
raise Execption()