Py2neo 搜索错误
Py2neo searching error
我还在尝试用py2neo+flask+neo4j做一个社交网络。
我在使用 py2neo.I 搜索我的数据库时遇到问题想找到所有用户名包含特殊 string.For 示例的所有用户其用户名包含 "dav" .我写了下面的代码,但我不知道为什么会出现这个错误...
from py2neo import Graph
graph=Graph("http://neo4j:123@localhost:7474/ ")
def search(name):
users=graph.merge("Person")
for N in users:
print N['username']
这是我的错误:
Traceback (most recent call last):
File "", line 1, in
File "/home/ali/Desktop/flask/search.py", line 10, in search users=graph.cypher.execute('match (p:Person) return p'
File "/usr/local/lib/python2.7/dist-packages/py2neo/core.py", line 659, in cypher metadata = self.resource.metadata
File "/usr/local/lib/python2.7/dist-packages/py2neo/core.py", line 213, in metadata self.get()
File "/usr/local/lib/python2.7/dist-packages/py2neo/core.py", line 267, in get raise_from(self.error_class(message, **content), error)
File "/usr/local/lib/python2.7/dist-packages/py2neo/util.py", line 235, in raise_from raise exception py2neo.error.GraphError: HTTP GET returned response 404
你的URL不对,你应该改成这样:
Graph("http://neo4j:123@localhost:7474/db/data")
此外,您不能通过 merge
函数执行 cypher,您应该这样做:
users = graph.cypher.execute('match (p:Person) return p')
我还在尝试用py2neo+flask+neo4j做一个社交网络。
我在使用 py2neo.I 搜索我的数据库时遇到问题想找到所有用户名包含特殊 string.For 示例的所有用户其用户名包含 "dav" .我写了下面的代码,但我不知道为什么会出现这个错误...
from py2neo import Graph
graph=Graph("http://neo4j:123@localhost:7474/ ")
def search(name):
users=graph.merge("Person")
for N in users:
print N['username']
这是我的错误:
Traceback (most recent call last): File "", line 1, in
File "/home/ali/Desktop/flask/search.py", line 10, in search users=graph.cypher.execute('match (p:Person) return p' File "/usr/local/lib/python2.7/dist-packages/py2neo/core.py", line 659, in cypher metadata = self.resource.metadata
File "/usr/local/lib/python2.7/dist-packages/py2neo/core.py", line 213, in metadata self.get() File "/usr/local/lib/python2.7/dist-packages/py2neo/core.py", line 267, in get raise_from(self.error_class(message, **content), error)
File "/usr/local/lib/python2.7/dist-packages/py2neo/util.py", line 235, in raise_from raise exception py2neo.error.GraphError: HTTP GET returned response 404
你的URL不对,你应该改成这样:
Graph("http://neo4j:123@localhost:7474/db/data")
此外,您不能通过 merge
函数执行 cypher,您应该这样做:
users = graph.cypher.execute('match (p:Person) return p')