All checks were successful
Gitea Docker Redeploy / Redploy-App-on-self-via-SSH (push) Successful in 3m9s
39 lines
938 B
Python
39 lines
938 B
Python
|
|
|
|
|
|
|
|
from neo4j import GraphDatabase
|
|
|
|
"""
|
|
pwd = "neo4j2"
|
|
proto = "bolt"
|
|
host = "192.168.99.101"
|
|
|
|
driver = GraphDatabase.driver("%s://%s:7687" % (proto, host), auth=("neo4j", pwd), encrypted=False)
|
|
|
|
def add_friend(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_friend, "Arthur", "Guinevere")
|
|
session.write_transaction(add_friend, "Arthur", "Lancelot")
|
|
session.write_transaction(add_friend, "Arthur", "Merlin")
|
|
session.read_transaction(print_friends, "Arthur")
|
|
|
|
driver.close()
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|