繁体   English   中英

py2neo:使用 cypher 内联给出 404 错误

[英]py2neo: using cypher inline gives 404 error

我在这里关注简单的py2neo教程: http://nicolewhite.github.io/neo4j-jupyter/hello-world.html

一切正常,所有条目都出现在 neo4j 浏览器版本中,但是当我尝试运行内联 Cypher 查询时,我收到 404 错误。

%%cypher
http://neo4j:password@localhost:7474/db/data/
MATCH (person:Person)-[:LIKES]->(drink:Drink)
RETURN person.name, drink.name, drink.calories

这是回溯:

Format: (http|https)://username:password@hostname:port/db/name
---------------------------------------------------------------------------
NotFoundError                             Traceback (most recent call last)
<ipython-input-12-de2d5705ff61> in <module>
----> 1 get_ipython().run_cell_magic('cypher', '', 'http://neo4j:password@localhost:7474/db/data/\nMATCH (person:Person)-[:LIKES]->(drink:Drink)\nRETURN person.name, drink.name, drink.calories\n')

~/.local/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
   2369             with self.builtin_trap:
   2370                 args = (magic_arg_s, cell)
-> 2371                 result = fn(*args, **kwargs)
   2372             return result
   2373 

<decorator-gen-127> in execute(self, line, cell, local_ns)

~/.local/lib/python3.6/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

<decorator-gen-126> in execute(self, line, cell, local_ns)

~/.local/lib/python3.6/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

~/.local/lib/python3.6/site-packages/cypher/magic.py in execute(self, line, cell, local_ns)
    106         user_ns.update(local_ns)
    107         parsed = parse("""{0}\n{1}""".format(line, cell), self)
--> 108         conn = Connection.get(parsed['as'] or parsed['uri'], parsed['as'])
    109         first_word = parsed['cypher'].split(None, 1)[:1]
    110         if first_word and first_word[0].lower() == 'persist':

~/.local/lib/python3.6/site-packages/cypher/connection.py in get(cls, descriptor, alias)
     45                 cls.current = conn
     46             else:
---> 47                 cls.current = Connection(descriptor, alias)
     48         if cls.current:
     49             return cls.current

~/.local/lib/python3.6/site-packages/cypher/connection.py in __init__(self, connect_str, alias)
     24                 gdb = GraphDatabase(self.connections[connect_str])
     25             else:
---> 26                 gdb = GraphDatabase(connect_str)
     27                 alias = alias or connect_str
     28         except:

~/.local/lib/python3.6/site-packages/neo4jrestclient/client.py in __init__(self, url, username, password, cert_file, key_file)
     81             response_json = response.json()
     82         else:
---> 83             raise NotFoundError(response.status_code, "Unable get root")
     84         if "data" in response_json and "management" in response_json:
     85             response = Request(**self._auth).get(response_json["data"])

NotFoundError: Code [404]: Not Found. Nothing matches the given URI.
Unable get root

我尝试在此处检查 URI 是否根据此答案工作,并且在那里也收到 404 错误:

~$ curl -i --user neo4j:password http://localhost:7474/db/data/
HTTP/1.1 404 Not Found
Access-Control-Allow-Origin: *
Cache-Control: must-revalidate,no-cache,no-store
Content-Type: text/html;charset=iso-8859-1
Content-Length: 0

我尝试设置Graph选项以包含链接,但没有帮助:

graph = Graph("http://neo4j:password@localhost:7474/db/data/")

你能告诉我我在哪里做错了吗?

我大部分时间都在使用 py2neo。 这是我连接到本地 neo4j 数据库的方法。

from py2neo import Graph
graph = Graph("bolt://localhost:7687", auth=("neo4j", "xxxxx"))
try:
    graph.run("Match () Return 1 Limit 1")
    print('ok')
except Exception:
    print('not ok')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM