problem with batch
Closed this issue · 1 comments
frostspb commented
Hello,
I use OrientDB 2.1.3 and pyorient 1.4.9. I have a problem with “batch” function - it throws an exception. Googling told me that pyorient might not work well with commands containing apostrophes, however it was also mentioned that this has been fixed in version 1.2.
Here is traceback:
Traceback (most recent call last):
File "tstor.py", line 41, in <module>
res = client.batch(cmd1)
File "/usr/local/projects/venvs/gns_rpc_env/local/lib/python2.7/site-packages/pyorient/orient.py", line 415, in batch
.prepare(( QUERY_SCRIPT, ) + args).send().fetch_response()
File "/usr/local/projects/venvs/gns_rpc_env/local/lib/python2.7/site-packages/pyorient/messages/commands.py", line 145, in fetch_response
super( CommandMessage, self ).fetch_response()
File "/usr/local/projects/venvs/gns_rpc_env/local/lib/python2.7/site-packages/pyorient/messages/base.py", line 256, in fetch_response
self._decode_all()
File "/usr/local/projects/venvs/gns_rpc_env/local/lib/python2.7/site-packages/pyorient/messages/base.py", line 240, in _decode_all
self._decode_header()
File "/usr/local/projects/venvs/gns_rpc_env/local/lib/python2.7/site-packages/pyorient/messages/base.py", line 192, in _decode_header
[ exception_message.decode( 'utf8' ) ]
pyorient.exceptions.PyOrientCommandException: com.orientechnologies.orient.core.exception.OSerializationExceptionjava.lang.IllegalArgumentException - Error on unmarshalling content. Class: com.orientechnologies.orient.core.command.script.OCommandScriptNo enum constant com.orientechnologies.orient.core.command.OCommandDistributedReplicateRequest.DISTRIBUTED_EXECUTION_MODE.begin;let acc = insert into Account(login, password) values('111', '123');create edge InGroup from $acc to (select from AccountGroup where name='Users');let usr = insert into User(Firstname, Middlename, Surname, Email) values('oleg', 'abbb', 'zzzzzzz', 'ssssssssss');create edge AccInUsr from $acc to $usr;commit retry 100;
Code snippet:
#-*- coding: utf-8 -*-
import pyorient
DB_HOST = 'localhost'
DB_PORT = 2424
DB_NAME = 'front_db'
DB_USER = 'adm'
DB_PSW = '***'
REQ_USER_SQL = ("begin;"
"let acc = insert into Account(login, password) values('{login}', '{password}');"
"create edge InGroup from $acc to (select from AccountGroup where name='Users');"
"let usr = insert into User(Firstname, Middlename, Surname, Email) values('{Firstname}', '{Middlename}', '{Surname}', '{Email}');"
"create edge AccInUsr from $acc to $usr;"
"commit retry 100;")
usr_dict = {'login': '111',
'password': '123',
'Firstname': 'oleg',
'Middlename': 'abbb',
'Surname': 'zzzzzzz',
'Email': 'ssssssssss'
}
cmd1 = REQ_USER_SQL.format(**usr_dict)
print cmd1
client = pyorient.OrientDB(DB_HOST, DB_PORT)
client.db_open(DB_NAME, DB_USER, DB_PSW)
res = client.batch(cmd1)
print res
frostspb commented
I've updated the database to version 2.1.15 and the problem was solved