我试图使用neo4j (1.6.4)在一个空的py2neo 2.1.2数据库中创建索引
我尝试了以下代码:
from py2neo import cypher
session = cypher.Session("http://localhost:7474")
tx = session.create_transaction()
tx.append("CREATE INDEX ON :Net(name)")
tx.append("CREATE INDEX ON :Key(name)")
tx.append("CREATE INDEX ON :Prop(name)")
tx.commit代码运行时没有错误,但对数据库不做任何操作。
如果我在neo4j浏览器中进行检查,输入
:schema我知道答案了
No indexes
No constraints如果我手动输入密码查询
CREATE INDEX ON :Net(name)紧接着是
:schema我得到了正确的答案
Indexes
ON :Net(name) ONLINE
No constraints我做错了什么?
发布于 2014-07-09 16:01:59
您需要使用tx.commit(),而不是tx.commit。您的代码运行时没有错误,因为tx.commit正在打印tx.commit方法,这很好,但是如果您想发送事务,可以使用tx.commit()。
https://stackoverflow.com/questions/24652647
复制相似问题