[英]Added a node to a graph connected via prompt with py2neo but MATCH (n) RETURN (n) shows empty graph in Neo4j browser
I am moving the first steps with py2neo.我正在使用 py2neo 迈出第一步。
I have created a graph via Neo4j Desktop我通过 Neo4j Desktop 创建了一个图表
DBMS Name: Neo4j
数据库管理系统名称:Neo4j
password: Neo4j
密码:Neo4j
and I have started it.我已经开始了。 Then I opened it with Neo4j browser, where it shows I am connected as user
neo4j
to bolt://localhost:7687
.然后我用 Neo4j 浏览器打开它,它显示我作为用户
neo4j
连接到bolt://localhost:7687
。
Then, I connected to it from my prompt by typing然后,我通过输入从提示连接到它
graph = Graph("bolt://localhost:7687", user="neo4j", password="Neo4j")
>>> graph
Graph('bolt://neo4j@localhost:7687')
I created a node我创建了一个节点
nicole = Node("person", name="Nicole", age=24)
>>> nicole
Node('person', age=24, name='Nicole')
and then I in my Neo4j browser, I expect to see my node if I type the query:然后我在我的 Neo4j 浏览器中,如果我键入查询,我希望看到我的节点:
MATCH (n) RETURN (n)
But it returns nothing.但它什么也不返回。
Why?为什么?
Also, if in my Chrome browser URL Bar I type http://localhost:7474/
, it returns the same view of the Neo4j browser ( MATCH (n) RETURN (n)
does not work even here )此外,如果在我的 Chrome 浏览器 URL Bar 中输入
http://localhost:7474/
,它会返回与 Z4F16D2B1F38F316B477DA6DBF0E9BC7nZRN 相同的视图(甚至在此处MATCH (n) RETURN (n)
)
but if in my Chrome browser URL Bar I type http://localhost:7687/
, it returns a void window with just the message但是如果在我的 Chrome 浏览器 URL Bar 中输入
http://localhost:7687/
,它会返回一个 void window 和消息
not a WebSocket handshake request: missing upgrade
不是 WebSocket 握手请求:缺少升级
Why I don't get a Neo4j-browser-like view even in this second case?为什么即使在第二种情况下我也没有得到类似 Neo4j 浏览器的视图?
Your code simply creates a local node.您的代码只是创建一个本地节点。 To create it in the graph, use:
要在图中创建它,请使用:
graph.create(nicole)
Then it will appear in your browser query.然后它将出现在您的浏览器查询中。
As mentioned in the comments, you need to use the graph.create()
to save the object in the database.正如评论中提到的,您需要使用
graph.create()
将 object 保存在数据库中。
graph = Graph("bolt://localhost:7687", user="neo4j", password="Neo4j")
>>> graph
Graph('bolt://neo4j@localhost:7687')
nicole = Node("person", name="Nicole", age=24)
>>> nicole
Node('person', age=24, name='Nicole')
>>> graph.create(nicole)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.