cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Latest neo4j driver doesn't return the data on non-empty database

ri8ika
Graph Voyager

Hi,
I am back after 2 years. I was using neo4j driver successfully before, but now it does not return any data. Not sure if there is any changes for this: (I am now using latest neo4j official driver)

with driver.session() as session:
      result = session.run("MATCH(n) RETURN n")
      print(result.data(), result.single())

[{'n': {}}] None

I have hard research for this and found nothing helpful.

1 ACCEPTED SOLUTION

ri8ika
Graph Voyager

Finally, I got it working after trying with very new simple python application. What I was doing wrong that printed result in with statement. Rather I have to separate run syntax outside of with session syntax. And printing value there works perfectly.

View solution in original post

4 REPLIES 4

It's working as intended. There is one node that contains no attributes: [{'n': {}}]. Note that after consuming a result, it's empty—like an iterator. So after calling result.data() or doing result_list = list(result), result.single() or repeating one of the above instructions will not give you the same data again. That's why result.single() returns None in your example.

ri8ika
Graph Voyager

Even if I just only use result.single(), it doesn't return the data. And the data() should result more nodes. There's something wrong I can't get the expected result.

After debugging, I got <neo4j.work.result.Result object, as far as I remember it should return <Node. object. I don't know what's going on.

ri8ika
Graph Voyager

Finally, I got it working after trying with very new simple python application. What I was doing wrong that printed result in with statement. Rather I have to separate run syntax outside of with session syntax. And printing value there works perfectly.

How does the run work outside the session context? Can you share your sample code?
i have a similar problem where i get result with 4.2 driver but not with 4.3.3 version. Its strange.