运行# 从Neo4j数据库中读取实体及其属性 with driver.session() as session: result = session.run("MATCH (n:attraction) RETURN n.entity as entity, n.name as name, n.time_reference as time_reference, n.address as address, n.open_time as open_time, n.ticket as ticket, n.region as region, n.lon as lon,n.lat as lat")报错ResultConsumedError: The result has been consumed. Fetch all needed records before calling Result.consume().
时间: 2024-02-26 10:52:28 浏览: 189
neovis.js:Neo4j + vis.js = neovis.js。 使用Neo4j中的数据在浏览器中图形化可视化-源码
5星 · 资源好评率100%
这个报错的意思是你在对已经消耗(consumed)完的结果对象进行操作。在使用Neo4j的Python驱动进行查询时,结果对象是一个迭代器,当你使用完这个迭代器后,它就会被自动消耗掉,所以你需要在使用结果之前将所有需要的记录都获取(fetch)到本地,然后再进行操作。
可以在执行查询时,使用 `result = session.run("MATCH (n:attraction) RETURN n.entity as entity, n.name as name, n.time_reference as time_reference, n.address as address, n.open_time as open_time, n.ticket as ticket, n.region as region, n.lon as lon,n.lat as lat").data()` 将结果取出到本地,这样就可以避免这个错误。
阅读全文