我已经创建了下面的 grakn 模式
define
contract sub relation,
relates manufacturer,
relates product;
drug sub entity,
plays product,
has product_name,
has code;
company sub entity,
plays manufacturer,
has manufacturer_name;
product_name sub attribute,
datatype string;
manufacturer_name sub attribute,
datatype string;
code sub attribute,
datatype string;
我有 3 个 csv(药物、公司和契约(Contract))
- 药物有产品名称(唯一)和代码
- 公司有 manufacturer_name(唯一)
- 契约(Contract)有 product_name 和 manufacturer_name(两者的唯一组合)
我正在使用 grakn 提供的同一个 migrate.py [修改表的名称]。在摄取过程中弹出以下错误。
<_RPC 的会合终止于: status = StatusCode.INVALID_ARGUMENT details = "GraqlSemanticException-name 没有 'isa'、'sub' 或 'id'。请检查服务器日志中的堆栈跟踪。" debug_error_string = "{"created":"@1588172437.178000000","description":"从对等 ipv4:127.0.0.1:48555 收到的错误","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"GraqlSemanticException-name 没有 'isa'、'sub' 或 'id'。请检查堆栈跟踪的服务器日志。","grpc_status":3}" >
在 grakn 提供的 phone_calls 示例中,我看到正在生成 ID(它是自动生成的吗?) 我需要将数据插入字段(公司、契约(Contract)和药品)。如果需要,我可以分享我编写的 migrate.py。
最佳答案
请检查您的 migrate.py 和 csv 文件中使用的名称。两者应该相同才能将数据插入 grakn-DB。例子: 如果您的查询是这样的:
'insert $company isa company, has name "' + company["name"] + '";'
因此在您的 csv 文件中,标题应该是“name”。 希望这会有所帮助。
关于python - 将数据插入 grakn 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61519866/