zoukankan      html  css  js  c++  java
  • GraphDatabase_action

    https://neo4j.com/docs/

    #https://pypi.python.org/pypi/neo4j-driver/1.5.3
    from neo4j.v1 import GraphDatabase

    driver = GraphDatabase.driver("bolt://localhost:7687", auth=("my@my.com","mypwd"))

    def add_friends(tx, name, friend_name):
    tx.run("MERGE (a:Person {name: $name}) "
    "MERGE (a)-[:KNOWS]->(friend:Person {name: $friend_name})",
    name=name, friend_name=friend_name)

    def print_friends(tx, name):
    for record in tx.run("MATCH (a:Person)-[:KNOWS]->(friend) WHERE a.name = $name "
    "RETURN friend.name ORDER BY friend.name", name=name):
    print(record["friend.name"])

    with driver.session() as session:
    session.write_transaction(add_friends, "Arthur", "Guinevere")
    session.write_transaction(add_friends, "Arthur", "Lancelot")
    session.write_transaction(add_friends, "Arthur", "Merlin")
    session.write_transaction(add_friends, "Arthur", "MyinputF")
    session.read_transaction(print_friends, "Arthur")






    Server version Neo4j/3.3.1
    Server address 127.0.0.1:7687
    Query MATCH (a:Person)-[:KNOWS]->(friend) WHERE a.name ="Arthur" RETURN friend.name ORDER BY friend.name
    Response
    [
      {
        "keys": [
          "friend.name"
        ],
        "length": 1,
        "_fields": [
          "Guinevere"
        ],
        "_fieldLookup": {
          "friend.name": 0
        }
      },
      {
        "keys": [
          "friend.name"
        ],
        "length": 1,
        "_fields": [
          "Lancelot"
        ],
        "_fieldLookup": {
          "friend.name": 0
        }
      },
      {
        "keys": [
          "friend.name"
        ],
        "length": 1,
        "_fields": [
          "Merlin"
        ],
        "_fieldLookup": {
          "friend.name": 0
        }
      },
      {
        "keys": [
          "friend.name"
        ],
        "length": 1,
        "_fields": [
          "Myinput"
        ],
        "_fieldLookup": {
          "friend.name": 0
        }
      },
      {
        "keys": [
          "friend.name"
        ],
        "length": 1,
        "_fields": [
          "MyinputF"
        ],
        "_fieldLookup": {
          "friend.name": 0
        }
      }
    ]
    Started streaming 5 records after 1 ms and completed after 1 ms.
     
     
     
     

    删除
     
    Deleted 5687 nodes, deleted 4885 relationships, completed after 453 ms.





  • 相关阅读:
    linux网络编程系列TCP及常用接口分析
    Linux网络编程系列TCP状态分析
    常见的HTTP 1.1状态代码及含义
    修改android SDK 模拟器(avd) 内存大小
    Android应用研发核心竞争力
    网路编程——阻塞式&&非阻塞式
    URI、URL和URN之间的区别与联系
    初识android——四大组件
    无依赖的combobox组件(autocomplete组件)
    为什么JS没有catchMyException或类似的方法
  • 原文地址:https://www.cnblogs.com/rsapaper/p/8310352.html
Copyright © 2011-2022 走看看