I've pushed data using gremlin-python. Now I want to run spcific queries on it. I'm using gizmo for that.
I basically want to achieve the degree of centrality for each node. How do I do that?
Currently I've query to return the same as :
g.V().group().
......1> by(id).
......2> by(union(__(), outE('mentions').count()).fold())
How I'm achieving that is:
def query(self, q):
from gizmo import Mapper, Request
from gremlinpy import Gremlin
req = Request('localhost', 8182)
gremlin = Gremlin('g')
mapper = Mapper(request=req, gremlin=gremlin)
# s = mapper.gremlin.V().inE('mentions').count().toList()
# res = mapper.query(gremlin=s)
# print(res.get_data()[0])
print("Something")
res = mapper.query(script=q)
# print(res.get_data()[0])
print("Something")
print(res.data)
print(res.first(), res.data)
# exit(0)
return res.first()
What I want is to display the data fetched inside res variable.
But each time I get errors as :
AttributeError: 'coroutine' object has no attribute 'data'
AttributeError: 'coroutine' object has no attribute 'get_data'
or anything similar which I try.
How do I fetch the results fetched from coroutine object?
NOTE: The sample query I'm passing to function query() is g.V().count()
Is there any other better way to run any generic queries from python in gremlin shell and fetch results?
Graph DB: JanusGraph
Backend: Cassandra
Indexing Backend: Elasticsearch
You mention gizmo which could relate to multiple projects, but I think you mean this one:
https://github.com/emehrkay/gizmo
According to the documentation, this project is meant for TinkerPop 2.x and Rexster. I don't believe it works with TinkerPop 3.x and Gremlin Server which is what JanusGraph is based on. If you need a Python OGM of some sort for TinkerPop 3.x you might consider:
https://github.com/davebshow/goblin