我正在尝试使用Oriented DB提取记录pyorient,这是我的查询:
query = "SELECT value FROM (SELECT expand(Elements) FROM dataset) WHERE type = 'XXX'"
records = client.command(query)
Run Code Online (Sandbox Code Playgroud)
一切都很好.当我尝试打印记录时,我得到的是:
record = records[0]
print type(record)
<class 'pyorient.otypes.OrientRecord'>
print record
{{'value': 'Name'},'version':0,'rid':'#-2:0'}
Run Code Online (Sandbox Code Playgroud)
因为我只需要提取' Name' record,我试过:
print record[0]
Run Code Online (Sandbox Code Playgroud)
得到了
TypeError: 'OrientRecord' object does not support indexing
Run Code Online (Sandbox Code Playgroud)
这是以下结果repr:
print(repr(record))
<pyorient.otypes.OrientRecord object at 0x7fdcdb531ad0>
Run Code Online (Sandbox Code Playgroud)
查看源代码后,我想出了如何从字符串表示中访问数据的各个部分:
>>> x
<pyorient.otypes.OrientRecord object at 0x105789e48>
>>> print(x)
{{'value': 'Name'},'version':0,'rid':'#-2:0'}
>>> x.oRecordData
{'value': 'Name'}
>>> x.value #allow for access in the oRecordData as attributes?
'Name'
>>> x._version, x._rid #other values in string representation
(0, '#-2:0')
Run Code Online (Sandbox Code Playgroud)
我很失望,字符串表示没有明显.无论如何,我认为你想要那个x.oRecordData.
| 归档时间: |
|
| 查看次数: |
1004 次 |
| 最近记录: |