建立Neo4j链接
bash
!pip install neo4j pyahocorasick numpy pandas --no-warn-script-location
定义数据操作对象
bash
from neo4j_driver import Neo4jConnection, Node
链接并查看节点数量
bash
conn = Neo4jConnection('neo4j://localhost:7687/', 'neo4j', 'Lorne@2022')
conn.create(Node("Person", name="Alice", age=30))
conn.create(Node("Person", name="Bob", age=30))
conn.create(Node("Person", name="Charlie", age=30))
print("数据库中的节点总数:", conn.counts())
创建所有关系
bash
# 创建关系
edges = [('Alice', 'Bob'), ('Alice', 'Charlie')]
conn.relationship('Person', 'Person', edges, 'KNOWS', 'friend')
清空所有的数据
bash
conn.clear()