orientechnologies / pyorient

OrientDB driver for Python that uses the binary protocol.
Apache License 2.0
119 stars 38 forks source link

Not working with orientdb 3.0 #27

Open tjtimer opened 6 years ago

tjtimer commented 6 years ago

I can't connect to my orientdb (version 3.0) database. Traceback: Traceback (most recent call last): File "", line 1, in File "/var/www/projects/pydev/bonham/venv/lib/python3.6/site-packages/pyorient/orient.py", line 411, in db_open info, clusters, nodes = self.get_message("DbOpenMessage") \ File "/var/www/projects/pydev/bonham/venv/lib/python3.6/site-packages/pyorient/orient.py", line 540, in get_message message_instance = _Message(self._connection)\ File "/var/www/projects/pydev/bonham/venv/lib/python3.6/site-packages/pyorient/messages/database.py", line 47, in init super(DbOpenMessage, self).init(_orient_socket) File "/var/www/projects/pydev/bonham/venv/lib/python3.6/site-packages/pyorient/messages/base.py", line 24, in init sock.get_connection() File "/var/www/projects/pydev/bonham/venv/lib/python3.6/site-packages/pyorient/orient.py", line 78, in get_connection self.connect() File "/var/www/projects/pydev/bonham/venv/lib/python3.6/site-packages/pyorient/orient.py", line 103, in connect " is not supported yet by this client.", []) pyorient.exceptions.PyOrientWrongProtocolVersionException: Protocol version 37 is not supported yet by this client.

linmao-song commented 6 years ago

Same here. Not sure if this project is still active? It seems to have been a while since last commit.

rrmerugu commented 6 years ago

i just updated the constants.py to support the lastest protocol 37 and its working, but not sure if it has any implications. Here is the working pyorient module for orientdb3.0.0 https://github.com/rrmerugu/pyorient/ you can install with pip install git+https://github.com/rrmerugu/pyorient/

Ostico commented 6 years ago

Should be tested, some internal changes could be happened. This requires manual test and debug.

Ostico commented 6 years ago

You can try, but keep in mind that this is not production ready.

rrmerugu commented 6 years ago

@Ostico is there any roadmap to support 3.0.0 soon ?

ghost commented 6 years ago

Same problem here. pyorient 1.5.5 orientdb 3.0.2

OrientDBColin commented 6 years ago

Starting with OrientDB 3.0.3, it adds a check to protocol 37 during the connect phase to see if a handshake is used. If a client specifies it supports protocol 37 but does not perform an initial handshake, it will fail.

The simplest solution is to still use protocol 36 (OrientDB will adjust accordingly) until the handshake, etc. can be implemented and to comment out this in orient.py:

        if self.protocol > SUPPORTED_PROTOCOL:
            raise PyOrientWrongProtocolVersionException(
                "Protocol version " + str(self.protocol) +
                " is not supported yet by this client.", [])

@Ostico could we comment that out, test it, and publish it to pip?

OrientDBColin commented 5 years ago

I went ahead and commented the protocol check out so that, at least, it will communicate with OrientDB 3.0.x now.

Your mileage may vary...

Ostico commented 5 years ago

Tested and checked with PHPOrient, this solution works, i will update pyOrient also as soon as possible

lalala0731 commented 5 years ago

@Ostico when can you updata it? I have the same problem.

thenesk commented 5 years ago

@Ostico, @mogui, any chance we could get this patch pushed to pypi?

Cornoualis commented 4 years ago

Until it's pushed to pypi, you can install the module via: pip install git+https://github.com/orientechnologies/pyorient

geastham commented 4 years ago

I forked a version and patched: https://github.com/OpenConjecture/pyorient

Install (be sure to use --upgrade flag to override local cache):

pip install --upgrade git+https://github.com/OpenConjecture/pyorient.git

Connect and test.

python
>> client = pyorient.OrientDB("localhost", 2424)
>> client.set_session_token(True)
>> session_id = client.connect( "admin", "admin" )
Konubinix commented 4 years ago

I am new to orientdb and I have been a little puzzled by all the forks and the lack of activity in pyorient, so maybe my comment will sound a little bit naive. Sorry.

I can tell that the fork https://github.com/OpenConjecture/pyorient appear to work so far.

It appears that, at least in 3.1.0, the binary protocol for error messages changed, causing pyorient to fail interpreting the binary output.

I generally get an output of the form

PyOrientCommandException                  Traceback (most recent call last)
~/perso/perso/python/clk_commands_perso/orientdb.py in <module>
----> 1 o.client.db_drop("docs")

~/.local/lib/python3.8/site-packages/pyorient/orient.py in db_drop(self, name, type)
    375         :return: None
    376         '''
--> 377         self.get_message("DbDropMessage") \
    378             .prepare((name, type)).send().fetch_response()
    379         return None

~/.local/lib/python3.8/site-packages/pyorient/messages/database.py in fetch_response(self)
    419 
    420     def fetch_response(self):
--> 421         return super(DbDropMessage, self).fetch_response()
    422 
    423     def set_db_name(self, db_name):

~/.local/lib/python3.8/site-packages/pyorient/messages/base.py in fetch_response(self, *_continue)
    263         # already fetched, get last results as cache info
    264         elif len(self._body) is 0:
--> 265             self._decode_all()
    266             self.dump_streams()
    267         return self._body

~/.local/lib/python3.8/site-packages/pyorient/messages/base.py in _decode_all(self)
    247 
    248     def _decode_all(self):
--> 249         self._decode_header()
    250         self._decode_body()
    251 

~/.local/lib/python3.8/site-packages/pyorient/messages/base.py in _decode_header(self)
    178                     del serialized_exception
    179 
--> 180             raise PyOrientCommandException(
    181                 exception_class.decode( 'utf8' ),
    182                 [ exception_message.decode( 'utf8' ) ]

PyOrientCommandException:  - 

Do you have a similar experience sometimes ?

Amioplk commented 3 years ago

Hello @Konubinix ! I have the same experience. Do you think it has anything to do with OrientDB 3.1+ version ? (I am currently using 3.1.6 version)

Konubinix commented 3 years ago

Sorry, I have given up using orientdb, as it is way to resource greedy to run on my Raspberry Pi 3B+. So I won't be able to answer you.