Question

I'm trying to query based on node number and return a list of properties. The following cypher query works in the neo4j browser but when I try to pass the same cypher query via py2neo I get:

"Expected a property container or number here, but got:91"

where "91" is the node number I'm querying on.

an excerpt from my code:

def neighbor_finder(a):
     try:                    
        graph_db = neo4j.GraphDatabaseService(url)                     

        query = neo4j.CypherQuery(graph_db,
         """CYPHER 2.0                         
            MATCH (n)-[r]-(m)            
            WHERE ID(n) = {t}
            WITH collect (Distinct m.size) as sizes, collect (Distinct m.weight) as weights, collect (Distinct m.color) as colors, collect (distinct n.label) as node_
            RETURN sizes, weights, colors, node_                                    
            """)                                                                                                                                     
        result = query.execute(t=a)

        for r in result:
            column = [str(item) for item in r.columns]
            value = [str(item) for item in r.values]                                             
            db_dict={k: v for k, v in zip(column, value)}
            for x, y in db_dict.items():
                print x, y

    except Exception as e:
        print e
Was it helpful?

Solution 2

argument "a" isn't being read because it needs to be declared as an integer, cypher/py2neo are currently reading it as a string.

OTHER TIPS

Can you provide details of the type and value of the a argument that is passed into this function? Without it I cannot see what py2neo is passing into the query parameters.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top