decode RID from LinkBag in pyorient

197 views
Skip to first unread message

finn

unread,
Jul 3, 2015, 6:24:54 AM7/3/15
to orient-...@googlegroups.com
Hi,

I realized that the previous question that I have asked is not clear and concise enough, so I did some research and ask it again :D.

I am testing the GRAPH example from GitHub:mogui/pyorient. The example creates a database named ‘animals’, within which exists a record #11:0. I use orient-console and got the record:

orientdb {db=animals}> select from animal
----+-----+------+----+------+--------
# |@RID |@CLASS|name|specie|out_Eat
----+-----+------+----+------+--------
0 |#11:0|Animal|rat |rodent|[size=1]
----+-----+------+----+------+--------

And I can get the type of the ‘out_Eat’ field like this:

orientdb {db=animals}> select out_Eat.type() from animal
----+------+-------
# |@CLASS|out_Eat
----+------+-------
0 |null |LINKBAG
----+------+———

However I can NOT get the RIDs of ‘out_Eat’ using pyorient. The related code and output is like:

>>> record = client.query("select * from Animal")[0]

>>> record.oRecordData
{'out_Eat': <pyorient.types.OrientBinaryObject object at 0x1018750b8>, 'name': 'rat', 'specie': 'rodent’}

>>> record.oRecordData['out_Eat']
<pyorient.types.OrientBinaryObject object at 0x1018750b8>

>>> record.oRecordData['out_Eat'].__dict__
{'b64': 'AQAAAAEADQAAAAAAAAAA’}

>>> record.oRecordData['out_Eat'].getBin()
b'\x01\x00\x00\x00\x01\x00\r\x00\x00\x00\x00\x00\x00\x00\x00’

>>> record.oRecordData['out_Eat'].getRaw()
‘_AQAAAAEADQAAAAAAAAAA_'

How can I get RID info stored in the ‘out_Eat’ field? Please throw in a light, thanks.

Raymond Michel

unread,
Sep 15, 2016, 10:12:32 PM9/15/16
to OrientDB, pref...@yahoo.com
Did you ever happen to find a solution to this? I'm having the same problem. Thanks!

user.w...@gmail.com

unread,
Sep 15, 2016, 11:10:12 PM9/15/16
to OrientDB, pref...@yahoo.com
Hi,

have you tried with this?

E.g

requiredObj = client.command("select from chat where name='%s' and room='%s'" % ("chat 1","1"));
print(requiredObj[0])

Hope it helps.
Regards

Raymond Michel

unread,
Sep 16, 2016, 2:22:31 AM9/16/16
to OrientDB, pref...@yahoo.com
Are you sure you're replying to the correct thread? This is asking about getting the RID information from a pyorient OrientBinaryObject that contains the RIDs of attached items.

alessand...@gmail.com

unread,
Sep 16, 2016, 3:38:21 AM9/16/16
to OrientDB, pref...@yahoo.com
Hi,
you could use these commands

requiredObj = client.command(' select expand(out("Eat")[0]) from Animal')


print(requiredObj[0]._rid)

For more information you can see this link


Hope it helps.
Alessandro

Graham Addis

unread,
Jan 30, 2018, 10:49:16 AM1/30/18
to OrientDB
Hi,

Any way of doing this without referring to the protected member "_rid".

It works, it's what I'm using, but not very pythonic...

Thanks,

Graham
Reply all
Reply to author
Forward
0 new messages