Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/297.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
Python Gremlin/Bulbflow:如何从execute()中获取整数结果_Python_Django_Neo4j_Gremlin_Bulbs - Fatal编程技术网

Python Gremlin/Bulbflow:如何从execute()中获取整数结果

Python Gremlin/Bulbflow:如何从execute()中获取整数结果,python,django,neo4j,gremlin,bulbs,Python,Django,Neo4j,Gremlin,Bulbs,抱歉,如果这个问题太愚蠢而不能问。。。我是Python+Django+Bulls+Neo4j的新手 我试图在使用Python+Django shell时获得由g.gremlin.execute()生成的整数,但没有成功,如下所述 首先,Neo4j的Gremlin控制台中的查询: gremlin> g.v(2).out ==> v[6] ==> v[4] ==> v[8] ==> v[7] gremlin> g.v(2).out.count() ==> 4

抱歉,如果这个问题太愚蠢而不能问。。。我是Python+Django+Bulls+Neo4j的新手

我试图在使用Python+Django shell时获得由g.gremlin.execute()生成的整数,但没有成功,如下所述

首先,Neo4j的Gremlin控制台中的查询:

gremlin> g.v(2).out
==> v[6]
==> v[4]
==> v[8]
==> v[7]
gremlin> g.v(2).out.count()
==> 4
我打算在Python+Django shell中实现这个结果,并将其传递给一个变量,如下所示:

>>> from bulbs.neo4jserver import Graph
>>> from bulbs.model import Node,Relationship
>>> g = Graph()
>>> sc = " g.v(vertex_id).out.count()"
>>> params = dict(vertex_id = 2)
>>> val = g.gremlin.execute(sc,params)
>>> val
<bulbs.neo4jserver.client.Neo4jResponse object at 0x243cfd0>
>>来自bulls.neo4jserver导入图
>>>从“关系”的“模型导入”节点
>>>g=图()
>>>sc=“g.v(顶点id).out.count()”
>>>params=dict(顶点id=2)
>>>val=g.gremlin.execute(sc,params)
>>>瓦尔
从现在起我再也走不动了

>>> val.one()
<bulbs.neo4jserver.client.Neo4jResult object at 0x2446b90>
>>> val.one().data
>>> val.one().results
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'Neo4jResult' object has no attribute 'results'
>>val.one()
>>>val.one().data
>>>val.one().results
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
AttributeError:'Neo4jResult'对象没有属性'results'
谁能告诉我我做错了什么?
非常感谢

原始结果数据将位于结果对象的
Raw
属性中:

>>> from bulbs.neo4jserver import Graph
>>> from bulbs.model import Node,Relationship
>>> g = Graph()
>>> script = " g.v(vertex_id).out.count()"
>>> params = dict(vertex_id = 2)
>>> resp = g.gremlin.execute(script,params)
>>> result = resp.one()
>>> result.raw
注意:
result.data
返回元素的属性数据,因此它将为空,除非您返回顶点或边,即Neo4j术语中的节点或关系

要查看Neo4j服务器在服务器响应中返回的内容,可以输出
响应
标题和内容:

>>> from bulbs.neo4jserver import Graph
>>> from bulbs.model import Node,Relationship
>>> g = Graph()
>>> script = "g.v(vertex_id).out.count()"
>>> params = dict(vertex_id = 2)
>>> resp = g.gremlin.execute(script,params)
>>> resp.headers
>>> resp.content
如果您在
Config
中将loglevel设置为
DEBUG
,您将能够看到每个请求发送到服务器的内容。启用
DEBUG
时,灯泡还会在
Response
对象上设置
raw
属性(不要与总是在
Result
对象上设置的
raw
属性混淆)<代码>响应。原始将包含原始服务器响应:

>>> from bulbs.neo4jserver import Graph, DEBUG
>>> from bulbs.model import Node,Relationship
>>> g = Graph()
>>> g.config.set_logger(DEBUG)
>>> script = " g.v(vertex_id).out.count()"
>>> params = dict(vertex_id = 2)
>>> resp = g.gremlin.execute(script,params)
>>> resp.raw

要关闭
调试
,请将日志级别设置回
错误

>>> from bulbs.neo4jserver import ERROR
>>> g.config.set_logger(ERROR)


原始结果数据将位于结果对象的
Raw
属性中:

>>> from bulbs.neo4jserver import Graph
>>> from bulbs.model import Node,Relationship
>>> g = Graph()
>>> script = " g.v(vertex_id).out.count()"
>>> params = dict(vertex_id = 2)
>>> resp = g.gremlin.execute(script,params)
>>> result = resp.one()
>>> result.raw
注意:
result.data
返回元素的属性数据,因此它将为空,除非您返回顶点或边,即Neo4j术语中的节点或关系

要查看Neo4j服务器在服务器响应中返回的内容,可以输出
响应
标题和内容:

>>> from bulbs.neo4jserver import Graph
>>> from bulbs.model import Node,Relationship
>>> g = Graph()
>>> script = "g.v(vertex_id).out.count()"
>>> params = dict(vertex_id = 2)
>>> resp = g.gremlin.execute(script,params)
>>> resp.headers
>>> resp.content
如果您在
Config
中将loglevel设置为
DEBUG
,您将能够看到每个请求发送到服务器的内容。启用
DEBUG
时,灯泡还会在
Response
对象上设置
raw
属性(不要与总是在
Result
对象上设置的
raw
属性混淆)<代码>响应。原始将包含原始服务器响应:

>>> from bulbs.neo4jserver import Graph, DEBUG
>>> from bulbs.model import Node,Relationship
>>> g = Graph()
>>> g.config.set_logger(DEBUG)
>>> script = " g.v(vertex_id).out.count()"
>>> params = dict(vertex_id = 2)
>>> resp = g.gremlin.execute(script,params)
>>> resp.raw

要关闭
调试
,请将日志级别设置回
错误

>>> from bulbs.neo4jserver import ERROR
>>> g.config.set_logger(ERROR)