从 cypher bolt 语句中获取结果
Fetching results from cypher bolt statement
我正在尝试使用 neo4j python 驱动程序 访问 neo4j。我是 运行 以下代码以获取 属性 thing A.,我直接从neo4j的GraphDatabase打开driver和session,使用session.run()执行图查询。这些查询 return BoltStatementResult object.My 问题是如何将这个对象转换为我需要的实际结果(属性 的东西 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")
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]
我正在尝试使用 neo4j python 驱动程序 访问 neo4j。我是 运行 以下代码以获取 属性 thing A.,我直接从neo4j的GraphDatabase打开driver和session,使用session.run()执行图查询。这些查询 return BoltStatementResult object.My 问题是如何将这个对象转换为我需要的实际结果(属性 的东西 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")
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]