Reputation: 468
I'm trying to use classes defined using py2neo to run graph queries on my database. Here's what I have so far:
py2neo.ogm import Graph, GraphObject, Property, RelatedTo, Label
gsb = Graph(address = "localhost:11004", password='<my_password>')
class Dataset(GraphObject):
__primarykey__ = 'title'
title = Property()
Dataset = Label()
class User(GraphObject):
__primarykey__ = 'user_id'
user_id = Property()
dept = Property()
email = Property()
name = Property()
eigenvector = property()
grantedAccess = RelatedTo("Dataset", "GRANTED_ACCESS_TO")
test_user = User.match(gsb, 'test_user').first()
for ds in test_user.grantedAccess:
print(ds.title)
What I was hoping for was a list of Datasets to which 'test_user' had been granted access. The equivalent cypher query would be:
MATCH (a:User)-[r:GRANTED_ACCESS_TO]->(b:Dataset)
WHERE a.user_id = 'test_user'
RETURN b.title
But when I run the python code I get nothing, not even an error message, just no results. I know the database connection is working correctly, and I know there are relationship patterns in the database that match the query. I'm assuming my query is written incorrectly somehow?
Can anyone explain why my python code returns no results?
Upvotes: 1
Views: 253
Reputation: 468
Well, it turns out this was just an embarrassing typo. The database documentation I was working from labeled the edge GRANTED_ACCESS_TO
but in the actual database it was GRANTED_ACCESS
. Once I made that change, everything worked as expected.
I'll let the mods decided whether it's worth keeping this question posted as a code example. Otherwise, feel free to delete.
Upvotes: 1