Advertisement

检测Neo4j query statement的返回结果是否为空

阅读量:
复制代码
    # 查找数据库中是否已有该组件
    cypher1 = "match (n{{name:'{0}'}}) return n".format(name)
    print("运行:cypher1 = ", cypher1 )
    node_list = graph.run(cypher1 ).data()
    print("node_list = ", node_list)
    
    # 如果数据库中没有该组件节点,则创造一个该节点
    if len(node_list) == 0:
    # 创建新组件节点
    cypher2 = "create (n:{0}{{name:'{1}'}})".format(label, name)
    print("运行:cypher2 = ", cypher2 )
    graph.run(cypher2 )
    
    

全部评论 (0)

还没有任何评论哟~