我正在尝试运行代码:
from py2neo import Graph
graph = Graph(config['DATABASE']['ENDPOINT'])
graph.data("MATCH (u:Users) return u.id, u.email LIMIT 4")
但是我收到错误消息:
AttributeError: 'Graph' object has no attribute 'data'
这与py2neo网站上给出的格式完全相同
from py2neo import Graph
graph = Graph(password="excalibur")
graph.data("MATCH (a:Person) RETURN a.name, a.born LIMIT 4")
[{'a.born': 1964, 'a.name': 'Keanu Reeves'},
{'a.born': 1967, 'a.name': 'Carrie-Anne Moss'},
{'a.born': 1961, 'a.name': 'Laurence Fishburne'},
{'a.born': 1960, 'a.name': 'Hugo Weaving'}]
关于错误消息的任何想法?
谢谢
最佳答案
我想您不在py2neo的版本3上,请尝试升级:
pip install py2neo --upgrade
这个简单的脚本可以正常工作:
from py2neo import Graph
graph = Graph(host="localhost")
d = graph.data("MATCH (t:TwitterAccount) RETURN t.user_screen_name LIMIT 4")
print(d)
--
ikwattro@graphaware ~/dev> python test.py
[{u't.user_screen_name': u'meichsnerbros'}, {u't.user_screen_name': u'renato_umeton'}, {u't.user_screen_name': u'kdnuggets'}, {u't.user_screen_name': u'sabrinaDijkhuiz'}]
ikwattro@graphaware ~/dev>