我正在尝试使用 neo4j python驱动程序访问neo4j。我正在运行以下代码来获取事物A 的属性。我打开驱动程序并进行会话直接从neo4j的GraphDatabase获取并使用 session.run()来执行图形查询。这些查询返回一个 BoltStatementResult 对象。我的问题是如何将该对象转换为我需要的实际结果(事物A的属性)。
from neo4j import GraphDatabase
uri = "bolt://abc:7687"
driver = GraphDatabase.driver(uri, auth=("neo4j", "password"))
def matchQuestion(tx, intent,thing):
result = tx.run("MATCH (e:thing) WHERE e.name = {thing}"
"RETURN e.description", thing=thing)
print(result)
with driver.session() as session:
session.read_transaction(matchQuestion, "define","A")
答案 0 :(得分:2)
result = tx.run("MATCH (e:thing) WHERE e.name = {thing}"
"RETURN e.description AS description", thing=thing)
for line in result:
print line["description"]
或
print result.single()
您还可以指定项目位置,例如-
print result.single()[0]