1

我正在尝试使用 pyorient 为两个顶点类创建一条边。我这样做的方式是;

vertex_class = client.command( "create class ABC extends V")
vertex_class = client.command( "create class my_class extends V")
edge_class = client.command("CREATE CLASS E12 EXTENDS E")
edge_class = client.command("create edge E12 from ABC to my_class")

顶点类和边类已成功创建,但是,我无法创建边。关于我做错了什么的任何想法?我是否必须先添加顶点,如果是,那么我如何在 pyorient 中做到这一点?

4

1 回答 1

1

该错误似乎与python无关。这个问题更像是一个 OrientDB 问题而不是 python 问题。创建边缘时,您必须指定资源 ID,或者您可以使用内联选择。我使用的是不同的示例,因为我不清楚您的顶点、边缘和链接。

CREATE CLASS Customer EXTENDS V
CREATE CLASS Account EXTENDS V
CREATE CLASS Owns EXTENDS E

CREATE VERTEX Customer SET name = 'John'
CREATE VERTEX Account SET accountnum = '12345678910'

#Option 1: You will have to get the rid of the vertices 
# You can use SELECT to get the record ID. 
# SELECT FROM Customer WHERE name = 'John'
# SELECT FROM Account where accountnum = '12345678910'
# Use the RID to create the edge
CREATE EDGE owns FROM #10:0 TO #11:0

#Option 2: You can use select inline which will create all the edges
CREATE EDGE Owns FROM ( SELECT FROM Customer where name = 'John' ) TO ( 
SELECT FROM Account where accountnum = '12345678910' )
于 2018-07-08T03:28:47.957 回答