Git Product home page Git Product logo

pyorient's People

Contributors

adityaketkar avatar blackhathedgehog avatar calthoff avatar devspacenine avatar diefans avatar guitarpoet avatar igordejanovic avatar josegomezr avatar killix avatar lebedov avatar lodrion avatar lvca avatar mogui avatar mokpro avatar nanvel avatar nikulukani avatar obi1kenobi avatar ostico avatar rochacbruno avatar schiv avatar spivachuk avatar thenesk avatar timgates42 avatar timothycrosley avatar tropicalpenguin avatar vadaszd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyorient's Issues

Update record

How do you update a record?
I need to insert a record and then update add the new record to another record's linked list

Failing to install using pip

Hi,

Trying to follow the instructions using pip install pyorient produces a partial egg (a lot of files are missing inside) and therefore, any attempt to use it fails.

Query ignore limit parameter

res = client.query("select from x limit 40")
len(res) #20
res = client.command("select from x limit 40")
len(res) #40

How do I get the edge number

So I have something like this:

{
    "result": [
        {
            "@type": "d",
            "@rid": "#13:0",
            "@version": 324,
            "@class": "Sondage",
            "in_vote_yes": [
                5
            ],
            "question": "Are you happy with your current job ?",
            "@fieldTypes": "in_vote_yes=g"
        },

I can get the question, easy with:

sondages_list = client.command("select from V where @Class='Sondage'")
sondage = sondages_list[0]

question = sondage.question

but it fails if I try to get "in_vote_yes"

I tried it with in_vote_yes = sondage.in_vote_yes[0]
but it fails with "OrientBinaryObject object does not support indexing.

Protocol 27

Hi and sorry for the noise.

As 2.0 is coming, the binary protocol is now at 27. When it was at 26, a simple bump in constant.py was making the trick, but now the connection request need to have a token-auth flag and extending pyorient code in this way is beyond my scope.

Here the text from https://github.com/orientechnologies/orientdb/wiki/Network-Binary-Protocol on protocol 27:
Since version 27 is introduced an extension to allow use a token based session, if this modality is enabled a few things change in the modality the protocol works.

in the first negotiation the client should ask for a token based authentication using the token-auth flag
the server will reply with a token or an empty byte array that means that it not support token based session and is using a old style session.
if the server don't send back the token the client can fail or drop back the the old modality.
for each request the client should send the token and the sessionId
the sessionId is needed only for match a response to a request
if used the token the connections can be shared between users and db of the same server, not needed to have connection associated to db and user.
protocol methods changed:

REQUEST_DB_OPEN

request add token session flag
response add of the token
REQUEST_CONNECT

request add token session flag
response add of the token

Failed to run record_create: self._cluster_id is a list not a string

Failed to run

    cluster_id = connection.client.command( "create class my_class extends V" )
    rec = { '@my_class': { 'accommodation': 'house', 'work': 'office', 'holiday': 'sea' } }
    rec_position = connection.client.record_create(cluster_id, rec)

RecordCreateMessage.py (line 51)
self._append( ( FIELD_SHORT, int(self._cluster_id) ) ) #self._cluster_id is a list not a string

Bug: retrieving EMBEDDEDMAP containing non-scalar items

Everything seems to work fine when retrieving an EMBEDDEDMAP with scalar items:

odb.command('create vertex v content {"embedded_map":{"one":2}}')[0].rid
'#9:101'
odb.query('select from #9:101')[0].oRecordData
{'embedded_map': {'one': 2}}

However, if stored EMBEDDEDMAP elements are lists or maps, those elements are added to the root element upon return:

odb.command('create vertex v content {"embedded_map":{"one":[1,2]}}')[0].rid
'#9:102'
odb.query('select from #9:102')[0].oRecordData
{'one': [1, 2], 'embedded_map': {}}

odb.command('create vertex v content {"embedded_map":{"one":{"three":4}}}')[0].rid
'#9:103'
odb.query('select from #9:103')[0].oRecordData
{'one': {'three': 4}, 'embedded_map': {}}

Graph example doesn't work - yOrientCommandException: Cannot find a command executor for the command request: sql

I tried to run example from GitHub "A GRAPH Example"

It fails at line
eat_edges = client.command("""
create edge Eat
from (select from Animal where name = 'rat')
to (select from Food where name = 'pea')
""")

with exception:

C:\Python27\python.exe C:/Eriks/PythonScripts/pyorient_tests.py
Traceback (most recent call last):
File "C:/test/PythonScripts/pyorient_tests.py", line 40, in
""")
File "C:\Python27\lib\site-packages\pyorient\orient.py", line 220, in command
.prepare(( QUERY_CMD, ) + args).send().fetch_response()
File "C:\Python27\lib\site-packages\pyorient\messages\commands.py", line 140, in fetch_response
super( CommandMessage, self ).fetch_response()
File "C:\Python27\lib\site-packages\pyorient\messages\base.py", line 143, in fetch_response
self._decode_all()
File "C:\Python27\lib\site-packages\pyorient\messages\base.py", line 127, in _decode_all
self._decode_header()
File "C:\Python27\lib\site-packages\pyorient\messages\base.py", line 115, in _decode_header
raise PyOrientCommandException(cmd_exc, [])
pyorient.exceptions.PyOrientCommandException: Cannot find a command executor for the command request: sql.
create edge Eat
from (select from Animal where name = 'rat')
to (select from Food where name = 'pea')

  • com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException

Process finished with exit code 1

Problem in serialization.py with Python3.x

In the README there is no indication about which Python versions are supported. As the library is really well written, it runs smoothly in Py3.3 except for some issues like this one:

At line 101 in the serialization.py file, the code triggers:

   File "/env/lib/python3.3/site-packages/pyorient/serialization.py", line 101, in parse_value
   elif isinstance(value, long):
        NameError: global name 'long' is not defined

In fact, in Python 3.x, int took the place of long.

records returning with negative cluster id in place of digit?

Hi, I am returning records from a class located (in this case) on cluster 12. However, the returned record rids are stating that the cluster id is -2.

It seems that I only have this issue when trying to filter the properties returned from the record. When returning all properties, the cluster id seems to return correctly.

e.g.
select * from some_class
returns the correct rid, whereas:
select some_property from some_class
returns the wrong rid.

Command length limit 127 characters

It appears that maximum length of the command to be sent is currently limited to 127 characters. If the length of the command supplied exceeds 127 characters a UnicodeDecodeError is returned. Is there any possibility to increase that or work around the limitation? Thanks.

DATETIME incorrectly deserialized as DATE

DATETIME projection is deserialized as datetime.date instead of datetime.datetime:

>>> DB.query("SELECT DATE('2015-01-02 03:04:05') FROM V")[0].oRecordData
{'date': datetime.date(2015, 1, 2)}

Index out of range at random moments

I keep running into this error and after hours and hours trying to figure out how it comes about I think it's time to ask for some help. I'm starting to feel like it's something fishy in PyOrient because I can't find the origin of this problem anywhere else.

The database is properly initialised and I manage to send 100s of batch commands without a problem and then all of a sudden I send a command like this (I seen no distinguishable difference to other commands that do succeed)

CommandsBEGIN;let entity = SELECT FROM #12:62437;let page = CREATE VERTEX Pages CONTENT {"url": "http://www.geolink.net.au/about/accreditations/", "timestamp": "2015-04-04 20:09:26", "corpus": "Accreditations | GeoLINK Home Featured Projects Our Services About Us Accreditations Company Profile Our Community Our Team Contact us Our Location Join Us Accreditations LATEST NEWS THE GREEN PAPER \u2013 NSW Government\u2019s New Planning System The NSW Planning Minister has recently released\u00a0The Green Paper, which sets out the government\u2019s... more \u00bb Pacific Pines Environmental Approvals in place This follows the State Government\u2019s approvals for the projects and will now enable a start on... more \u00bb GeoLINK now offers Road Safety Auditing! GeoLINK now offers Road Safety Audits in Tweed Heads, Lismore, Coffs Harbour, Newcastle and NSW... more \u00bb \u00a0 Quality Assurance GeoLINK\u2019s policy is to provide all products and services in accordance with the client\u2019s specified requirements and best practice. The quality of our work is assured through established, purpose designed project management systems and rigorous peer review processes. GeoLINK maintains a Quality Management System meeting the requirements of AS/NZS ISO 9001 and is third party certified by BSI Australia. Certificate of Registration \u00a0 \u00a0 \u00a0 Project Login Username Password Remember Me Lost PasswordQUICKLINKSHome Company Profile Accreditations Our Community Contact us Join Us Our Team Past Projects LATEST NEWS THE GREEN PAPER \u2013 NSW Government\u2019s New Planning System Pacific Pines Environmental Approvals in place GeoLINK now offers Road Safety Auditing! NSW State Government Updates the Planning System 12th Annual Tree Planting Day at Lennox Head CONTACT USLennox Head Office PO Box 119 (Level 1, 64 Ballina Street) Lennox Head, NSW 2478 Tel: +61 (0) 2 6687 7666 Coffs Harbour Office PO Box 1446 (23 Gordon Street) Coffs Harbour, NSW 2450 Tel: +61 (0) 2 6651 7666 Lismore OfficeUnit 10, Warina Walk Arcade156 Molesworth StreetLismore\u00a0 NSW\u00a0 2480 \u00a9 2015 GeoLINK Website design by Coast Studios. Find us on Facebook or Linked In"} RETURN AFTER @rid;let e = CREATE EDGE has_pages FROM $entity TO $page;COMMIT;SELECT @rid as key from $page;

and I get the following exception:

Traceback (most recent call last): File "process_items.py", line 84, in createPageVertex page = self.odb.batch(commands) File "/Users/rik/anaconda/lib/python2.7/site-packages/pyorient/orient.py", line 246, in batch .prepare(( QUERY_SCRIPT, ) + args).send().fetch_response() File "/Users/rik/anaconda/lib/python2.7/site-packages/pyorient/messages/commands.py", line 149, in fetch_response return self._read_sync() File "/Users/rik/anaconda/lib/python2.7/site-packages/pyorient/messages/commands.py", line 197, in _read_sync res.append( self._read_record() ) File "/Users/rik/anaconda/lib/python2.7/site-packages/pyorient/messages/base.py", line 407, in _read_record _res = ORecordDecoder(__res['content'].rstrip()) File "/Users/rik/anaconda/lib/python2.7/site-packages/pyorient/serialization.py", line 17, in __init__ self.__decode( content ) File "/Users/rik/anaconda/lib/python2.7/site-packages/pyorient/serialization.py", line 36, in __decode chunk = self.parse_key(content) File "/Users/rik/anaconda/lib/python2.7/site-packages/pyorient/serialization.py", line 104, in parse_key if content[ 0 ] == '"': IndexError: string index out of range

Does it have anything todo with maybe a bug in the deserialisation of the Unicode corpus body?

Failed to run client.record_create - first arg should be a String not a List

using example:

cluster_id = client.command( "create class my_class extends V" )
rec = { '@my_class': { 'accommodation': 'house', 'work': 'office', 'holiday': 'sea' } }

rec_position = client.record_create( cluster_id[0], rec) ##### pass

rec_position = client.record_create( cluster_id, rec) ##### fails

self._append( ( FIELD_SHORT, int(self._cluster_id) ) )
TypeError: int() argument must be a string or a number, not 'list'

DECIMAL properties are typecasted to int

The driver tries to typecast properties of type DECIMAL to int. Example using the public VehicleHistoryGraph database:

>>> client.query("SELECT price FROM transaction")
Traceback (most recent call last):
...
ValueError: invalid literal for int() with base 10: '16477.53'
orientdb {db=VehicleHistoryGraph}> INFO CLASS transaction

PROPERTIES
-------------------------------+-------------+
 NAME                          | TYPE        |
-------------------------------+-------------+
 price                         | DECIMAL     |

How record_create for Edge should look like?

I tried and failed :

    class_id1 = connection.client.command( "create class my_v_class extends V" )
    class_id2 = connection.client.command( "create class my_e_class extends E" )
    rec1 = { '@my_v_class': { 'accommodation': 'house', 'work': 'office', 'holiday': 'sea' } }
    rec2 = { '@my_v_class': { 'accommodation': 'house', 'work2': 'office', 'holiday': 'sea3' } }
    rec_position1 = connection.client.record_create(class_id1, rec1)
    rec_position2 = connection.client.record_create(class_id2, rec2)

    rec3 = { '@my_e_class': {  '@to': rec_position2.rid, '@from': rec_position1.rid} }
    rec_position3 = connection.client.record_create(class_id2, rec3)

Doc enhancement

I'd appreciate some info in the docs on how to connect in a web app (say Flask).
Can the Client be global? Should the connection be opened for each request? Should the connection be closed (how?)

TIA

Setup broken

Missing /src folder, setup.py gives <warning: no files found matching 'src/*'>.
The resulting python module is missing the /Common and /Messages folders, giving <ImportError: No module named Commons.OrientException> when trying to import.

Driver not handling @rid projection

The driver seems to mishandle the projection of @Rid during a query. Since the following is a projection, oRecordData['rid'] should be set to '#11:0'. Instead the RID is stored as the generated document's RID and not part of the projection. Also, if I'm not mistaken, record.rid should be equal to #-1:-1 in this case, since projections result in temporary documents.

>>> record = DB.query("SELECT @rid, @class FROM #11:0")[0]
>>> record.oRecordData
{'class': 'Article'}                     <--- missing `rid' projection
>>> record.rid
<pyorient.types.OrientRecordLink object at 0x7fbad1fc4a20>
>>> str(record.rid)
'#11:0'                                  <--- there it is; shouldn't this be #-1:-1 instead?

Console and Studio produce the following results, properly projecting the record meta data to strings:

orientdb {db=testdb}> SELECT @rid, @class FROM V
----+------+-----+-------
#   |@CLASS|rid  |class
----+------+-----+-------
0   |null  |#11:0|Class1
1   |null  |#12:0|Class2
2   |null  |#13:0|Class3

Temporary workaround

Currently, in cases when I need to retrieve and re-use a RID and want to access it through oRecordData, I have to project it under a different name:

>>> DB.query("SELECT @rid as oid FROM #11:0")[0].oRecordData['oid']
<pyorient.types.OrientRecordLink object at 0x7fbad1fc4b00>

I'm personally not very fond of OrientRecordLink, especially because I often end up encoding record data into JSON strings. This results in me having to force OrientDB to convert it to a string first:

>>> DB.query("SELECT @rid.asString() as oid FROM #11:0")[0].oRecordData['oid']
'#11:0'

Alternatively, its string representation seems to work fine for now.

>>> str(DB.query("SELECT @rid as oid FROM #11:0")[0].oRecordData['oid'])
'#11:0'

Set retrieval not working

The drivers seems to have troubles retrieving/deserializing sets.

>>> DB.query("SELECT set('test') FROM V")[0].oRecordData
{'set': []}

Expected result, confirmed with Studio, is as follows:

{'set': ["test"]}

To clarify, this causes issues when, for example, trying to project something like field.keys(), with field referring to a property of type EMBEDDEDMAP:

>>> DB.query("SELECT l10n.keys() FROM #11:0")[0].oRecordData
{'l10n': []}
>>> DB.query("SELECT l10n.keys().asString() FROM #11:0")[0].oRecordData
{'l10n': '[en, de, da, ru]'}

Not on pip

pyorient 1.0.0 is yet to be uploaded on the Python Package Index

Using PyOrient in Multi-process approaches

Can I use the same instance of client object concurrently.
ie,
I have several objects that need persist and query data in Orientdb.
All of them work concurrently.

Can I create only one instance of Client Object and share it with all of them?

Connection timeout/interruption detection

The driver performs no checks for timeouts or server restart which results in blocking calls to the socket's recv() method.

If a timeout occurs or the server is restarted while a pyorient instance is active, it is possible to cause a KeyboardInterrupt (when using a CLI) or set additional checks/timeouts outside the module before calling the driver's methods.

An argument could be made that this is an enhancement that has to be implemented before the driver can actually be used in a production environment, especially when deployed with WSGI instances.

Cannot use "dir" or ipython autocomplete on client

client = pyorient.OrientDB("localhost", 2424)
client.connect("admin", "admin")
dir(client)
---------------------------------------------------------------------------
PyOrientBadMethodCallException            Traceback (most recent call last)
<ipython-input-9-c835ea810ed1> in <module>()
----> 1 dir(client)

pyorient/pyorient/orient.pyc in __getattr__(self, item)
    158 
    159         _names = "".join( [i.capitalize() for i in item.split('_')] )
--> 160         _Message = self.get_message(_names + "Message")
    161 
    162         def wrapper(*args, **kw):

pyorient/pyorient/orient.pyc in get_message(self, command)
    298         except KeyError as e:
    299             raise PyOrientBadMethodCallException(
--> 300                 "Unable to find command " + str(e), []
    301             )

PyOrientBadMethodCallException: Unable to find command 'DirMessage'

Missing import in OrientDB.py

There is a missing "import pyorient" in the OrientDB.py

This causes a query to fail with the message:

...
py2.7.egg/pyorient/OrientDB.py", line 98, in query
.prepare(( pyorient.QUERY_SYNC, ) + args).send().fetch_response()
NameError: global name 'pyorient' is not defined

Bug: fetch_response after creating vertex with empty EMBEDDEDMAP

Failure when parsing resource returned after creation if it contains an empty EMBEDDEDMAP element:

FAILURE odb.command('create vertex v content {"a":1,"b":{},"c":3}')

Although, it works if the EMBEDDEDMAP is not empty or if there are no other elements after the empty EMBEDDEDMAP:

SUCCESS odb.command('create vertex v content {"a":1,"b":{"d":"e"},"c":3}')
SUCCESS odb.command('create vertex v content {"a":1,"b":{}}')

record_load() fails when loading a non-existing record

Is it by design that record_load() does not handle cases where the provided RID does not exist in the database? client.record_load("#(non-existing RID)") raises KeyError and an AttributeError. Perhaps it would be nicer to simply return None or raise a custom exception?

PyOrient Select Query no result with dynamic strings

I'm trying to use select query in a flask application to find a username but if I use dynamic strings I got nothing but if I user static one I got my proper result. Here is my sample code:

@web.route('/register/', methods=['GET', 'POST'])
@login_not_required
def register():
    form = RegisterForm()
    text = "SELECT * FROM user WHERE username =  'hamidfzm'"
    print db.connection.command(text)
   # I got result but from the these above lines I got nothing
    text = "SELECT * FROM user WHERE username =  '%s'" % "hamidfzm"
    print db.connection.command(text)

    text = "SELECT * FROM user WHERE username =" +  " 'hamidfzm'"
    print db.connection.command(text)

    text = "SELECT * FROM user WHERE username =  '%s'" % form.username.data"
    print db.connection.command(text)
    return 'just a test'

edge.in leads to syntax error

# A rat that eats pea
edge = client.command(
    """create edge eat from (
              select from animals where name = 'rat'
     ) to (
         select from food where name = 'pea'
    )
   """
)

edge.out.get()
'11:0'

client.record_load(edge.out.get()).name
'rat'

# Now I want to get the pea

client.record_load(edge.in.get()).name
  File "<ipython-input-47-c89ea3396a55>", line 1
    client.record_load(edge.in.get()).specie
                             ^
SyntaxError: invalid syntax

Pyorient won't unlock database

Hi, I'm trying to use pyorient to create a database, but it doesn't seem to unlock the database afterwards.

With the environment variable ODB_URL=orientdb://root:foo@localhost:2424/test, I'll run this script:

#!/usr/bin/env python

import os
import pyorient
import urllib.parse

def main():
    print(os.environ["ODB_URL"])
    parsed = urllib.parse.urlparse(os.environ["ODB_URL"])
    conn = pyorient.OrientDB(parsed.hostname, parsed.port)
    conn.connect(parsed.username, parsed.password)
    conn.db_create(parsed.path[1:], pyorient.DB_TYPE_GRAPH, pyorient.STORAGE_TYPE_PLOCAL)
    conn.db_close()

if __name__ == "__main__":
    main()

The process exits normally. Everything appears fine until using OrientDB's console.sh afterwards, which gives this error:

orientdb>  connect plocal:/home/vagrant/orientdb/databases/test root foo;

Connecting to database [plocal:/home/vagrant/orientdb/databases/test] with user 'root'...
Error: com.orientechnologies.orient.core.exception.OStorageException: Cannot open local storage '/home/vagrant/orientdb/databases/test' with mode=rw

Error: com.orientechnologies.orient.core.exception.OSerializationException: Cannot load database's configuration. The database seems to be corrupted.

Error: com.orientechnologies.common.concur.lock.OLockException: File '/home/vagrant/orientdb/databases/test/database.ocf' is locked by another process, maybe the database is in use by another process. Use the remote mode with a OrientDB server to allow multiple access to the same database.

double property types returning as strings?

I initially thought this was due to updating to the newest version, but I see that this behaviour also occurred with the prior version:

'Double' type properties are returning as strings, whereas 'integer' type properties are returning as integers. Is there some trick to getting the Doubles to return as floats in Python?

Support SSL

You will have support for SSL Connection?

Trouble retrieving EMBEDDEDLISTs containing EMBEDDEDMAPs

Storing an EMBEDDEDMAP works as expected:

>>> DB.command("CREATE VERTEX V SET mapInList = { 'one': 2, 'three': 4 }")[0].oRecordData
{'mapInList': {'one': 2, 'three': 4}}

So does placing the EMBEDDEDMAP in an EMBEDDEDLIST:

>>> DB.command("CREATE VERTEX V SET mapInList = [ { 'one': 2 } ]")[0].oRecordData
{'mapInList': [{'one': 2}]}

However, adding elements to the same EMBEDDEDMAP makes the driver hang/block:

>>> DB.command("CREATE VERTEX V SET mapInList = [ { 'one': 2, 'three': 4 } ]")[0].oRecordData

iterate records with pyorient

if there is a possibility to iterate trough records in class or cluster? or i have to create a loop to load records..thanks

Failed to run SQL batch: Cannot find a command executor

Failed to run batch as described in

            https://github.com/orientechnologies/orientdb/wiki/SQL-batch

pyorient.Commons.OrientException.PyOrientCommandException: Cannot find a command executor for the command request: sql.begin
let a = create vertex set script = true
let b = select from v limit 1
let e = create edge from $a to $b
commit retry 100
return $e - com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException

Can I use prepared commands with pyorient?

Can I use prepared commands with pyorient?

Something like:
insert into Person (name, age) values (:name, :age) or
insert into Person (name, age) values (?, ?)

and then, submit the prepared command several times against database with different values for bind variables.

Bug deserializing data containing boolean values

Performing a query that returns fields of type BOOLEAN results in what seems to be an infinite loop.
Steps to reproduce bug:

client.command("create vertex v content {'a':false}")
client.query("select from v")

pyorient version: commit a37d133 (14/11/2014)
OrientDB version : 2.0-M1

Deserialization: quotes

The driver seems to have problems deserializing content with quotation marks:

>>> import json
>>> test_data = {'scenario': 'a "quote" follows'}

>>> record = DB.command("CREATE VERTEX V CONTENT " + json.dumps(test_data))[0]

>>> record.rid, record.oRecordData
('#9:27', {'scenario': 'a "'})

>>> DB.query("SELECT FROM " + record.rid)[0].oRecordData
{'scenario': 'a "'}

Console shows it is stored properly:

orientdb {db=testdb}> SELECT FROM #9:27

----+-----+------+-----------------
#   |@RID |@CLASS|scenario
----+-----+------+-----------------
0   |#9:27|V     |a "quote" follows
----+-----+------+-----------------

Database user credentials not enough to access database

The driver does not allow to open a database without connecting to the server instance using server credentials first.

In other words, ODB console allows to use credentials set as the OUser documents in the DB without using the credentials defined in `orientdb-server-config.xml':

orientdb> connect remote:localhost/test admin admin
Connecting to database [remote:localhost/test] with user 'admin'...OK

pyorient, on the other hand, does not allow to do so without caling OrientDB.connect() first:

>>> import pyorient ; client = pyorient.OrientDB("localhost", 2424) ; client.db_open("test", "admin", "admin")
...
pyorient.exceptions.PyOrientCommandException: b'Wrong user/password to [connect] to the remote OrientDB Server instance. Get the user/password from the config/orientdb-server-config.xml file - com.orientechnologies.orient.core.exception.OSecurityAccessException'

error datetime decode

I run this command:
client.command("create edge my from #12:3903 to #12:3913 set date_s = '2014-08-27 17:21:29'")
Property date_s has DATETIME type.

And get error:
Traceback (most recent call last):
File "create_graph.py", line 93, in
res = client.command("create edge my from #12:3903 to #12:3913 set date_s = '2014-08-27 17:21:29'")
File "/usr/lib64/python2.7/site-packages/pyorient-1.1.2-py2.7.egg/pyorient/orient.py", line 204, in command
.prepare(( QUERY_CMD, ) + args).send().fetch_response()
File "/usr/lib64/python2.7/site-packages/pyorient-1.1.2-py2.7.egg/pyorient/messages/commands.py", line 145, in fetch_response
return self._read_sync()
File "/usr/lib64/python2.7/site-packages/pyorient-1.1.2-py2.7.egg/pyorient/messages/commands.py", line 193, in _read_sync
res.append( self._read_record() )
File "/usr/lib64/python2.7/site-packages/pyorient-1.1.2-py2.7.egg/pyorient/messages/base.py", line 335, in _read_record
_res = ORecordDecoder( __res['content'].rstrip() )
File "/usr/lib64/python2.7/site-packages/pyorient-1.1.2-py2.7.egg/pyorient/serialization.py", line 156, in init
self.__decode()
File "/usr/lib64/python2.7/site-packages/pyorient-1.1.2-py2.7.egg/pyorient/serialization.py", line 189, in __decode
self._stateCase[self._state](char, c_class)
File "/usr/lib64/python2.7/site-packages/pyorient-1.1.2-py2.7.egg/pyorient/serialization.py", line 474, in __state_number
token_value = datetime.fromtimestamp(float(self._buffer))
ValueError: year is out of range

I think, line 474 in serialization.py should be changed from
token_value = datetime.fromtimestamp(float(self._buffer))
to
token_value = datetime.fromtimestamp(float(self._buffer) / 1000)

OrientRecord impl creates name clash on "@<property>" vs "<property>"?

I'm just now checking out pyorient for the first time, and the first test I tried with the client resulted in unexpected behavior.

My test wants to use a schema like the following:

{'@Package': {'name': 'foo', 'version': '1.0.0'}}

While this seems to be perfectly valid in OrientDB, I've discovered that the way records are implemented in pyorient creates a name clash between special @property names and normal property names. So with @version being a special property in OrientDB, it just becomes aRecord.version in pyorient, and makes it seemingly invalid to use as a user property.

Example:

$ rec = {'@Package': {'name': 'foo', 'version': '1.0.0'}}
$ client.record_create(cid, rec)
PyOrientCommandException: The field 'Package.version' is mandatory, but not found on record:
Package{name:foo} - com.orientechnologies.orient.core.exception.OValidationException

Since version is being claimed by the python impl to represent the @version, it doesn't allow it to be a normal user property, which seems to be an unnecessary limitation. The same would be true if you had a user field called rid

Can this behavior be confirmed? Is it expected?

socket.timeout: timed out - client.query("select count(*) from followed_by")

The program is failing to run the query ()

  db = client.db_open( "GratefulDeadConcerts", "admin", "admin" )
  print client.db_count_records()
  print client.query("select count(*) from followed_by")

result:

7868
Traceback (most recent call last):
File "C:/Users/rang/PycharmProjects/ran/test1.py", line 13, in
client.query("select count(*) from followed_by")
File "C:\Users\rang\PycharmProjects\ran\lib\site-packages\pyorient\OrientDB.py", line 99, in query
.prepare(( pyorient.QUERY_SYNC, ) + args).send().fetch_response()
File "C:\Users\rang\PycharmProjects\ran\lib\site-packages\pyorient\Messages\Database\CommandMessage.py", line 83, in fetch_response
void = super( CommandMessage, self ).fetch_response()
File "C:\Users\rang\PycharmProjects\ran\lib\site-packages\pyorient\Messages\BaseMessage.py", line 135, in fetch_response
self._decode_all()
File "C:\Users\rang\PycharmProjects\ran\lib\site-packages\pyorient\Messages\BaseMessage.py", line 118, in _decode_all
self._decode_header()
File "C:\Users\rang\PycharmProjects\ran\lib\site-packages\pyorient\Messages\BaseMessage.py", line 79, in _decode_header
self._header = [ self._decode_field( FIELD_BYTE ),
File "C:\Users\rang\PycharmProjects\ran\lib\site-packages\pyorient\Messages\BaseMessage.py", line 208, in _decode_field
_value = self._orientSocket.read( _type['bytes'] )
File "C:\Users\rang\PycharmProjects\ran\lib\site-packages\pyorient\Messages\OrientSocket.py", line 98, in read
raise e
socket.timeout: timed out

OrientEngine

Hi, @Ostico , @mogui

I am starting a new project based in PyOrient (it will be PyOrient dependent)

I have large experience with MongoEngine and I contributed a little bit with some PR's, So now that I am using OrientDB I think it will be nice to have something like MongoEngine to Orient.

Are you guys willing to collaborate, participate, etc?

Now there is only the syntax definition, now I have some sketches running on my machine, and I am doing some tests to push the first version.

https://github.com/rochacbruno/OrientEngine

What you think about it?

Failed to execute the query select @rid, firstName from my_class

result = cliento.query("select @Rid, firstName from my_class")

Traceback (most recent call last):
  File "/home/pollitux/webapps/ConnectOrient.py", line 284, in <module>
    main()
  File "/home/pollitux/webapps/ConnectOrient.py", line 269, in main
    comisiones()
  File "/home/pollitux/webapps/ConnectOrient.py", line 248, in comisiones
    result = cliento.query("select @rid, firstName from my_class")
  File "/usr/local/lib/python2.7/dist-packages/pyorient/orient.py", line 205, in query
    .prepare(( QUERY_SYNC, ) + args).send().fetch_response()
  File "/usr/local/lib/python2.7/dist-packages/pyorient/messages/commands.py", line 140, in fetch_response
    return self._read_sync()
  File "/usr/local/lib/python2.7/dist-packages/pyorient/messages/commands.py", line 187, in _read_sync
    res.append( self._read_record() )
  File "/usr/local/lib/python2.7/dist-packages/pyorient/messages/base.py", line 333, in _read_record
    rid=__res['rid'], version=__res['version']
  File "/usr/local/lib/python2.7/dist-packages/pyorient/types.py", line 17, in __init__
    self._set_keys(content)
  File "/usr/local/lib/python2.7/dist-packages/pyorient/types.py", line 23, in _set_keys
    setattr( self, key, content[key] )
AttributeError: can't set attribute

I tried the query in the studio and working properly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.