簡體   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