Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing bytes into OGM object throws an exception #40

Open
FredPraca opened this issue Sep 1, 2020 · 1 comment
Open

Writing bytes into OGM object throws an exception #40

FredPraca opened this issue Sep 1, 2020 · 1 comment

Comments

@FredPraca
Copy link

Using the following class representation:

class Sensor(Node):
     name = String()
     zone = String()
     photo = Binary()

I'm able to create the schema in the database using the Node registry without any problem.

When trying to insert values using:

graph.create_vertex(Sensor,
       name = 'test',
       zone = 'z1',
       photo = bytes_read)

where bytes_read comes from

with open('/home/test/Images/test.png', 'rb') as f:
     bytes_read = f.read();

I got the following stacktrace

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "/home/test/.local/lib/python3.6/site-packages/pyorient/ogm/graph.py", line 546, in create_vertex
    to_unicode(self.create_vertex_command(vertex_cls, **kwargs)))[0]
  File "/home/test/.local/lib/python3.6/site-packages/pyorient/orient.py", line 463, in command
    .prepare(( QUERY_CMD, ) + args).send().fetch_response()
  File "/home/test/.local/lib/python3.6/site-packages/pyorient/messages/commands.py", line 144, in fetch_response
    super( CommandMessage, self ).fetch_response()
  File "/home/test/.local/lib/python3.6/site-packages/pyorient/messages/base.py", line 265, in fetch_response
    self._decode_all()
  File "/home/test/.local/lib/python3.6/site-packages/pyorient/messages/base.py", line 249, in _decode_all
    self._decode_header()
  File "/home/test/.local/lib/python3.6/site-packages/pyorient/messages/base.py", line 182, in _decode_header
    [ exception_message.decode( 'utf8' ) ]
pyorient.exceptions.PyOrientSQLParsingException: com.orientechnologies.orient.core.sql.OCommandSQLParsingException - Lexical error at line 1, column 57.  Encountered: "x" (120), after : "\'\\"
	DB name="test"
	Error Code="1"

I suspect the binary is not correctly encoded as in PropertyEncoder, I don't find ay case to serialize Binary object.

@FredPraca FredPraca changed the title Writings bytes into OGM throw an exception Writing bytes into OGM object throws an exception Sep 1, 2020
@brucetony
Copy link

I was able to patch the library to work with OrientDB 3.1+ and updated the README to give descriptions of how to connect to your database now. You can find my patched version here: https://github.com/brucetony/pyorient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants