我正在尝试创建一个链接到特定类的条目
cluster_id = -1
res = client.command('SELECT * FROM Role WHERE name="User"')
user_role = res[0]
rec = { '@Person': { 'first_name': 'joe', 'last_name': 'soap', 'username': 'soapj', 'roles':user_role._rid } }
res = client.record_create(cluster_id, rec)
但是当我这样做时,我得到了:
Traceback (most recent call last):
File "project/dbtest.py", line 40, in <module>
res = client.record_create(cluster_id, rec )
File "/project/pyorient/orient.py", line 442, in record_create
.prepare(args).send().fetch_response()
File "/project/pyorient/messages/records.py", line 99, in fetch_response
result = super( RecordCreateMessage, self ).fetch_response()
File "/project/pyorient/messages/base.py", line 256, in fetch_response
self._decode_all()
File "/project/pyorient/messages/base.py", line 240, in _decode_all
self._decode_header()
File "/project/pyorient/messages/base.py", line 192, in _decode_header
[ exception_message.decode( 'utf8' ) ]
pyorient.exceptions.PyOrientCommandException: java.lang.ArrayIndexOutOfBoundsException -
但是,如果我使用原始SQL,它可以工作:
res = client.command('SELECT * FROM Role WHERE name="User"')
user_role = res[0]
rec = "INSERT INTO Person SET first_name='joe', last_name='soap', username='soapj', roles=%s" % user_role._rid
res = client.command(rec)
有没有办法使用pyorient的本机方法,或者我是否需要下载到原始sql?