Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gremlin Python Gizmo如何在图形数据库中查询_Python_Graph_Gremlin_Janusgraph - Fatal编程技术网

Gremlin Python Gizmo如何在图形数据库中查询

Gremlin Python Gizmo如何在图形数据库中查询,python,graph,gremlin,janusgraph,Python,Graph,Gremlin,Janusgraph,我已经使用gremlin python推送了数据。现在我想对它运行spcific查询。我用gizmo来做这个 我基本上希望实现每个节点的中心度。我该怎么做 目前,我有一个要返回的查询,如下所示: g.V().group(). ......1> by(id). ......2> by(union(__(), outE('mentions').count()).fold()) 我是如何做到这一点的: def query(self, q): from gizmo import M

我已经使用gremlin python推送了数据。现在我想对它运行spcific查询。我用gizmo来做这个

我基本上希望实现每个节点的中心度。我该怎么做

目前,我有一个要返回的查询,如下所示:

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()

有没有其他更好的方法在GremlinShell中从python运行任何通用查询并获取结果

图形数据库:JanusGraph

后端:Cassandra


索引后端:Elasticsearch

您提到的gizmo可能涉及多个项目,但我认为您指的是这个:

根据文档,这个项目是为Tinkerpop2.x和Rexster设计的。我不相信它能与Tinkerpop3.x和Gremlin服务器一起工作,而这正是JanusGraph的基础。如果TinkerPop 3.x需要某种Python OGM,您可以考虑:


谢谢,地精似乎在我们的问题用例中起作用。:-)