簡體   English   中英

OrientDB:在pyorient中為兩個頂點類創建邊

[英]OrientDB: Creating Edges for two vertex classes in pyorient

我正在嘗試使用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中添加頂點?

該錯誤似乎與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' )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM