Hi all,
When I use batch() function of pyorient, I encounter a very strange problem.
I did it following such steps:

*1. create and open db using pyorient;*
*2. create class and edge; *
*3. using batch() function for test*

core codes is like this:
*cluster_id = client.command("create class fb extends V")*
*cluster_id = client.command("create class response extends V")*
*cluster_id = client.command("create class followed_by extends E")*
*cluster_id = client.batch("begin;create vertex fb set name = 'd1';create 
vertex response set name = 'a1';create edge followed_by from fb to 
response;commit;")*

the last line of the code will report such an error:
*  File "loaddata_to_orientdb.py", line 62, in <module>*
*    cluster_id = client.batch("begin;create vertex fb set name = 
'd1';create vertex response set name = 'a1';create edge followed_by from fb 
to response;commit;")*
*  File 
"/root/workplace/orientdb/env/lib/python2.7/site-packages/pyorient/orient.py", 
line 208, in batch*
*    .prepare(( QUERY_SCRIPT, ) + args).send().fetch_response()*
*  File 
"/root/workplace/orientdb/env/lib/python2.7/site-packages/pyorient/utils.py", 
line 47, in wrap_function*
*    return wrap(*args, **kwargs)*
*  File 
"/root/workplace/orientdb/env/lib/python2.7/site-packages/pyorient/utils.py", 
line 60, in wrap_function*
*    return wrap(*args, **kwargs)*
*  File 
"/root/workplace/orientdb/env/lib/python2.7/site-packages/pyorient/messages/commands.py",
 
line 131, in prepare*
*    return super( CommandMessage, self ).prepare()*
*  File 
"/root/workplace/orientdb/env/lib/python2.7/site-packages/pyorient/messages/base.py",
 
line 72, in prepare*
*    self._encode_field( x ) for x in self._fields_definition*
*  File 
"/root/workplace/orientdb/env/lib/python2.7/site-packages/pyorient/messages/base.py",
 
line 72, in <genexpr>*
*    self._encode_field( x ) for x in self._fields_definition*
*  File 
"/root/workplace/orientdb/env/lib/python2.7/site-packages/pyorient/messages/base.py",
 
line 200, in _encode_field*
*    buf = v.encode('utf-8')*
*UnicodeDecodeError: 'utf8' codec can't decode byte 0x81 in position 77: 
invalid start byte*

It sounds like the utf8 code problem, but I have already added such lines 
in the start of my program:
*# -*- coding: utf-8 -*-*
*import sys*
*import pyorient*
*reload(sys)*
*sys.setdefaultencoding('utf-8')*

The more strange is that when i use the clause
*cluster_id = client.batch("begin;create vertex fb set name = 'd1';create 
vertex response set name = 'a1';commit;")*
instead of 
*cluster_id = client.batch("begin;create vertex fb set name = 'd1';create 
vertex response set name = 'a1';create edge followed_by from fb to 
response;commit;")*
Then the error disappeared and the records were created successfully. Is 
this an bug of pyorient?

Could anybody give me a hand, thanks in advance!

Regards!

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to