在Neo4j中创建节点时遇到问题
path_data = "BPI2000sample.csv"
df = pd.read_csv(path_data)
uri= "bolt://localhost:7687"
driver = GraphDatabase.driver(uri,auth=("neo4j","123456"))
session = driver.session()
def create_contsraint(tx):
tx.run("use loan1 CREATE CONSTRAINT ON (e:Event) ASSERT e.name IS UNIQUE;")
tx.run("use loan1 CREATE CONSTRAINT ON (c:Case) ASSERT c.name IS UNIQUE;")
tx.run("use loan1 CREATE CONSTRAINT ON (r:Resource) ASSERT r.name IS UNIQUE;")
session.write_transaction(create_contsraint)
with session.begin_transaction() as tx:
for row in df[df.case.unique == cases].iterrows():
j = j + 1
msg = tx.run("use loan1 MERGE (c:Case {name: $case})", case= row[0])
print(msg)
#msg = tx.run("use loan1 MERGE (c:Case {name: $case})", case=row[0])
#row = cursor.fetchone()
tx.success = True # commit the cypher statements
print("total nodes created:",j)
它写了约束但没有创建节点这里的问题是什么?
1条答案
按热度按时间eqqqjvef1#
收到的消息是什么?我怀疑您不能使用
:use loan1
来定义数据库,它通常是在会话级别设置的:然后道: