py2neo create()方法节点无法创建但不报错

from py2neo import Graph, Node, Relationship, NodeMatcher

# 数据库
graph = Graph(config.database_address,
                      username="neo4j",
                      password="123456")
# 备份数据库
graph_bak = Graph(config.database_address_backup,
                  username="neo4j",
                  password="123456")

label = "City"
attrs = {"name":"BeiJing"}
a = Node(label, **attrs)
# 在数据库中创建节点
graph.create(a)
# 在备份数据库中创建节点
graph_bak.create(a)               # bug
  • 以上代码只能在数据库中创建节点
  • graph_bak.create(a)失效,无法在备份数据库中创建节点
  • 修改如下:
from py2neo import Graph, Node, Relationship, NodeMatcher

# 数据库
graph = Graph(config.database_address,
                      username="neo4j",
                      password="123456")
# 备份数据库
graph_bak = Graph(config.database_address_backup,
                  username="neo4j",
                  password="123456")

label = "City"
attrs = {"name":"BeiJing"}
a = Node(label, **attrs)
b = Node(label, **attrs)         # debug
# 在数据库中创建节点
graph.create(a)
# 在备份数据库中创建节点
graph_bak.create(b)              # debug

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