0
votes

I am moving the first steps with py2neo.

I have created a graph via Neo4j Desktop

DBMS Name: Neo4j

password: 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.

enter image description here

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:

MATCH (n) RETURN (n)

But it returns nothing.

  1. Why?

  2. 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 )

enter image description here

but if in my Chrome browser URL Bar I type http://localhost:7687/, it returns a void window with just the message

not a WebSocket handshake request: missing upgrade

Why I don't get a Neo4j-browser-like view even in this second case?

2
you have just created an object. To create the node in graph, you need to execute graph.create(nicole).Rajat Mishra
Thanks @Rajat, type it as answer and I will flag it as correct.Tms91
thanks.. i have added it as an answerRajat Mishra

2 Answers

1
votes

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.

1
votes

As mentioned in the comments, you need to use the graph.create() to save the object in the database.

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)

You can read more here