首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OrientDB:在pyorient中为两个顶点类创建边

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

Stack Overflow用户
提问于 2018-07-08 02:22:20
回答 1查看 439关注 0票数 1

我试图使用pyorient为两个顶点类创建一个边。我所做的就是;

代码语言:javascript
复制
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中这样做呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-08 03:28:47

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

代码语言:javascript
复制
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' )
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51228377

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档