Gremlin Python Gizmo 如何在图形数据库中查询
Gremlin Python Gizmo how to query in graph db
我使用 gremlin-python 推送了数据。现在我想 运行 对其进行具体查询。我为此使用了小发明。
我基本上是想达到每个节点的中心度。我该怎么做?
目前我查询 return 与 :
相同
g.V().group().
......1> by(id).
......2> by(union(__(), outE('mentions').count()).fold())
我是如何做到的:
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()
我想要的是显示在res变量中获取的数据。
但每次我都收到错误:
AttributeError: 'coroutine' object has no attribute 'data'
AttributeError: 'coroutine' object has no attribute 'get_data'
或我尝试过的任何类似的东西。
如何获取从协程对象获取的结果?
注意:我传递给函数 query() 的示例查询是 g.V().count()
是否有任何其他更好的方法来 运行 在 gremlin shell 中来自 python 的任何通用查询并获取结果?
图数据库: JanusGraph
后端:卡桑德拉
索引后端: Elasticsearch
你提到的 gizmo 可能与多个项目相关,但我认为你指的是这个:
https://github.com/emehrkay/gizmo
根据文档,该项目适用于 TinkerPop 2.x 和 Rexster。我不相信它可以与 TinkerPop 3.x 和 JanusGraph 所基于的 Gremlin Server 一起使用。如果您需要 Python TinkerPop 3.x 的某种 OGM,您可以考虑:
我使用 gremlin-python 推送了数据。现在我想 运行 对其进行具体查询。我为此使用了小发明。
我基本上是想达到每个节点的中心度。我该怎么做?
目前我查询 return 与 :
相同g.V().group().
......1> by(id).
......2> by(union(__(), outE('mentions').count()).fold())
我是如何做到的:
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()
我想要的是显示在res变量中获取的数据。
但每次我都收到错误:
AttributeError: 'coroutine' object has no attribute 'data'
AttributeError: 'coroutine' object has no attribute 'get_data'
或我尝试过的任何类似的东西。
如何获取从协程对象获取的结果?
注意:我传递给函数 query() 的示例查询是 g.V().count()
是否有任何其他更好的方法来 运行 在 gremlin shell 中来自 python 的任何通用查询并获取结果?
图数据库: JanusGraph
后端:卡桑德拉
索引后端: Elasticsearch
你提到的 gizmo 可能与多个项目相关,但我认为你指的是这个:
https://github.com/emehrkay/gizmo
根据文档,该项目适用于 TinkerPop 2.x 和 Rexster。我不相信它可以与 TinkerPop 3.x 和 JanusGraph 所基于的 Gremlin Server 一起使用。如果您需要 Python TinkerPop 3.x 的某种 OGM,您可以考虑: