OrientDB:在 pyorient 中为两个顶点 类 创建边

OrientDB: Creating Edges for two vertex classes in pyorient

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

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")

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

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

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' )