py2neo 数据类型

from py2neo.data import Node, Relationship
a = Node("Person", name="Alice")  # 创建一个节点
b = Node("Person", name="Bob")  # 创建另一个节点
ab = Relationship(a, "KNOWS", b)  # 两个节点建立关系
ab

1.Node

class py2neo.data.Node(*labels, **properties)
类方法属性 描述
node == other 如果两个node相等返回true
node != other
hash(node) 返回对象ID
node[key] 返回节点的属性,没有返回none
node[key] = value 设置node值,如果为none则是删除节点属性
del node[key] 删除node属性,如果属性不存在,则报错
len(node) 返回节点属性的个数
dict(node) 返回节点属性字典
walk(node) 迭代node
node.labels 返回节点标签
label in node.labels 如果存在该标签,则返回true
node.labels.add(label) 添加节点的标签
node.labels.discard(label) 删除节点的标签
node.labels.remove(label) 删除节点标签,如果不存在,则报错
node.labels.clear() 清除节点所有标签
node.labels.update(labels) Add multiple labels to node from the iterable labels.

2.relationship

class py2neo.data.Relationship(start_node, type, end_node, **properties)
class py2neo.data.Relationship(start_node, end_node, **properties)
class py2neo.data.Relationship(node, type, **properties)
class py2neo.data.Relationship(node, **properties)
类方法属性 描述
relationship==other 如果相等返回true
relationship!=other 如果不等返回true
hash 返回关系开始节点的哈希值
relationship[key] 返回关系的属性
relationship[key] = value 设置关系属性,如果为none,删除关系属性
del relationship[key] 删除关系的属性,如果不存在报错
len(relationship) 查看关系属性个数
dict(relationship) 将关系属性转换为字典
walk(relationship)
type(relationship) 查看关系属性的类型

3.subgraph

subgraph是节点和关系的集合.一个subgraph必须至少有一个节点.

class py2neo.data.Subgraph(nodes, relationships)
类方法 描述
subgraph | other | … 并集,Union
subgraph & other & … 交集,Intersection
subgraph - other - 差集,Difference
subgraph ^ other ^ … Symmetric difference
subgraph.keys() 返回节点和关系的属性
subgraph.labels() 返回节点标签
subgraph.nodes() 返回所有节点
subgraph.relationships() 返回所有关系
subgraph.types() 返回关系类型

4. walkable

5.objects

6.Table

你可能感兴趣的:(数据库)