forked from xzk-seu/360KG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbolt_request.py
28 lines (22 loc) · 865 Bytes
/
bolt_request.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from neo4j.v1 import GraphDatabase
def run():
uri = "bolt://localhost:7687"
driver = GraphDatabase.driver(uri, auth=("neo4j", "1234"))
with driver.session() as session:
with session.begin_transaction() as tx:
result = tx.run("MATCH (n) RETURN n LIMIT 2")
# for record in tx.run("MATCH (a:Person)-[:KNOWS]->(f) "
# "WHERE a.name = {name} "
# "RETURN f.name", name=name):
# print(record["f.name"])
print(result.records())
for r in result.records():
print(r.data())
print(type(r.data()))
data = r.data()['n']
print(type(data))
print(data.items())
# for resu in result:
# print(resu)
if __name__ == '__main__':
run()