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

How record_create for Edge should look like? #12

Closed
rangilboa opened this issue Oct 4, 2014 · 5 comments
Closed

How record_create for Edge should look like? #12

rangilboa opened this issue Oct 4, 2014 · 5 comments

Comments

@rangilboa
Copy link

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)
@Ostico
Copy link
Collaborator

Ostico commented Oct 4, 2014

Hi,
try this:

class_id1 = client.command( "create class my_v_class extends V" )[0]
class_id2 = client.command( "create class my_e_class extends E" )[0]
rec1 = { '@my_v_class': { 'accommodation': 'house', 'work': 'office', 'holiday': 'sea' } }
rec2 = { '@my_v_class': { 'accommodation': 'house', 'work2': 'office', 'holiday': 'sea3' } }
rec_position1 = client.record_create(class_id1, rec1)
rec_position2 = client.record_create(class_id2, rec2)
sql_edge = "create edge from " + rec_position1.rid + " to " + rec_position2.rid
res = client.command( sql_edge )

@Ostico Ostico closed this as completed Oct 4, 2014
@rangilboa
Copy link
Author

Is there a way to all in one transaction?

It look like only record_create is supported by tx
On Oct 4, 2014 10:32 PM, "Ostico" notifications@github.com wrote:

Hi,
try this:

class_id1 = client.command( "create class my_v_class extends V" )[0]
class_id2 = client.command( "create class my_e_class extends E" )[0]
rec1 = { '@my_v_class': { 'accommodation': 'house', 'work': 'office', 'holiday': 'sea' } }
rec2 = { '@my_v_class': { 'accommodation': 'house', 'work2': 'office', 'holiday': 'sea3' } }
rec_position1 = client.record_create(class_id1, rec1)
rec_position2 = client.record_create(class_id2, rec2)
sql_edge = "create edge from " + rec_position1.rid + " to " + rec_position2.rid
res = client.command( sql_edge )


Reply to this email directly or view it on GitHub
#12 (comment).

@Ostico
Copy link
Collaborator

Ostico commented Oct 4, 2014

Seems not to be possible, TX_COMMIT support only record update/create/delete
https://github.com/orientechnologies/orientdb/wiki/Network-Binary-Protocol#request_tx_commit
so our driver don't implement that feature.

I can ask to orientdb creators if there is a workaround or what is the right way to do that.

@rangilboa
Copy link
Author

Thanks for the quick answer!!!

The problem I am trying to solve is

Persisting Vertices and Edges in one transaction (tx).

It looks like there is a solution for Vertices but note for Edges.

I am new to pyorientdb and maybe there is a better solution ...

ran

On Oct 5, 2014 12:13 AM, "Ostico" notifications@github.com wrote:

Seems not to be possible, TX_COMMIT support only record
update/create/delete

https://github.com/orientechnologies/orientdb/wiki/Network-Binary-Protocol#request_tx_commit
so our driver don't implement that feature.

I can ask to orientdb creators if there is a workaround or where is the
right way to do that.


Reply to this email directly or view it on GitHub
#12 (comment).

@Ostico Ostico reopened this Oct 6, 2014
@Ostico Ostico closed this as completed Oct 6, 2014
@Ostico
Copy link
Collaborator

Ostico commented Oct 12, 2014

Now you can use batch command

mokpro added a commit to mokpro/pyorient that referenced this issue Oct 27, 2014
cmd_str = create edge eats_at from mogui#12:7343 to mogui#17:27746 set created_at ="2014-10-24"   
cl.command(cmd_str)
  File "/Library/Python/2.7/site-packages/pyorient-1.1.1-py2.7.egg/pyorient/orient.py", line 204, in command
    .prepare(( QUERY_CMD, ) + args).send().fetch_response()
  File "/Library/Python/2.7/site-packages/pyorient-1.1.1-py2.7.egg/pyorient/messages/commands.py", line 145, in fetch_response
    return self._read_sync()
  File "/Library/Python/2.7/site-packages/pyorient-1.1.1-py2.7.egg/pyorient/messages/commands.py", line 193, in _read_sync
    res.append( self._read_record() )
  File "/Library/Python/2.7/site-packages/pyorient-1.1.1-py2.7.egg/pyorient/messages/base.py", line 335, in _read_record
    _res = ORecordDecoder( __res['content'].rstrip() )
  File "/Library/Python/2.7/site-packages/pyorient-1.1.1-py2.7.egg/pyorient/serialization.py", line 156, in __init__
    self.__decode()
  File "/Library/Python/2.7/site-packages/pyorient-1.1.1-py2.7.egg/pyorient/serialization.py", line 189, in __decode
    self._stateCase[self._state](char, c_class)
  File "/Library/Python/2.7/site-packages/pyorient-1.1.1-py2.7.egg/pyorient/serialization.py", line 475, in __state_number
    token_value = datetime.fromtimestamp(float(self._buffer))
ValueError: year is out of range
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