Are there any real instructions for using py2neo?

py2neo

(A Bramson) #1

I am using py2neo v4 with Python 3.6 and it's really hard to just get basic things done because there is basically no real instructions or examples. The official documentation " The Py2neo v4 Handbook" at https://py2neo.org/v4/index.html" is basically worthless because it doesn't include any examples of using most of the code and there is no description of how anything works there.

As a concrete example, I've got a node using
thisNode = list(matcher.match('Label1'))[0]
And now I want to get the list of nodes connected to this node via a particular kind of relationship.
I think this Cypher query works:
`list(graph.run("MATCH (n1)<-[:PARTOF]-(n2) WHERE ID(n1) = $thisID RETURN n2", parameters={"thisID":thisPrefNode.identity}).data())
And the question is: How do I do that in py2neo without using Cypher?
Since the parent node is already stored in a variable in python, this should be an easy thing to do, but...

And the broader question is where can I go real/learn about how py2neo works? There is barely any assistance on Stack Exchange, most of which is obsolete anyway. Is py2neo basically just not supported? In that case, is there a better way to interface between Python and Neo4j?


(A Bramson) #2

For this specific question, I actually found a partial answer in the handbook:

for rel in graph.match((alice, ), r_type="FRIEND"): print(rel.end_node["name"])

but, for my case the direction is in the wrong direction. The syntax is totally opaque, and the only guidance on what to even try to get the desired results is from the minimalist documentation: Parameters: nodes – Sequence or Set of start and end nodes (None means any node); a Set implies a match in any direction

There are no real instructions to explain the syntax nor any other examples for other use cases (like mine).
By trial and error I was able to figure out that
for rel in graph.match((None,alice), r_type="FRIEND"): print(rel.start_node["name"])
actually gets me what I want in this case, but by just putting a few more examples in the documentation would clarify the syntax and help many (and especially new) users.


(A Bramson) #3

So I guess the answer is "No. There is no real support or documentation for py2neo. And there is no better way for Python to interact with Neo4j. You're on your own and it's totally hopeless." That's pretty sad if you are looking for customers for your technology.


(Andrew Bowman) #4

Looks like your post fell through the cracks, sorry about that. Let's get that fixed up.

You may want to try using the Python bolt driver as the means to interface with Neo4j via Cypher

Or if you want to stick with Py2Neo, here's a blog post with some examples of usage:


(A Bramson) #5

Thank you for responding, but if those are the two best sources you can point me to, then it seems the answer hasn't changed. There is basically no real explanation or useful examples for the vast majority of the commands listed in the documentation, and no resources for getting help learning to use Neo4j or its Python drivers.

I'm working on a pilot project using graph databases in my company, but after my experiences struggling for hours to perform basic functions, I really can't recommend this technology. Not because of what it can and cannot do, but because there is no way to train our engineers to do what they need to do.

I highly recommend committing serious time/effort in some actual instruction and more complete documentation (basically just add a lot more examples covering a lot more use cases to the documentation). You might also considering having people respond to posts on Stack Exchange and/or your own forum.


(Andrew Bowman) #6

Regarding the Python bolt driver, the page I linked to should have additional links at the bottom to our drivers documentation which should be applicable for all drivers (including Python)

https://neo4j.com/docs/developer-manual/current/drivers/

I just wanted to make sure you've visited that part of the documentation, as it does contain examples of usage.

When using the bolt drivers, most of your Python code around driver usage won't change much, it will just be the Cypher executed (and perhaps parameters passed) and how you consume the results that will change.


(Andrew Bowman) #7

One additional thing to keep in mind...

Py2Neo isn't officially company supported. It's a community driver, volunteer-based project, and while there are some engineers who contribute to it, it's not something Neo4j the company has adopted for full support/documentation/love+care. We'll do best-effort, and get those involved who contribute to the project, but it is not a Neo4j product.

The Python bolt drivers, however, are under the company's stewardship, so we have official documentation and examples present, which I've linked to.


(Andrew Bowman) #8

As for using Neo4j itself, we do have plenty of resources, starting with our developers manual, but we certainly are not lacking here.

Here's a few links to start with:

https://neo4j.com/docs/developer-manual/3.4/

If you have questions about certain aspects or topics in our documentation, we're more than happy to point you in the right direction.