简体   繁体   English

如何在python中使用RDFLIB运行SPARQL更新语句

[英]How to run a SPARQL update statement using RDFLIB in python

I know there is an update statement in SPARQL, but I am not really sure how to use it in RDFLIB.我知道 SPARQL 中有一个更新语句,但我不确定如何在 RDFLIB 中使用它。 For instance, I have an ontology that contains Alice and Julius as individuals and I want to run a SPARQL update to change their properties.例如,我有一个包含 Alice 和 Julius 作为个体的本体,我想运行 SPARQL 更新来更改他们的属性。 This includes things like updating their ages, likes, hobbies, etc.这包括更新他们的年龄、喜好、爱好等。

I also want to be able to add individuals and their properties if they do not exist in the ontology.如果本体中不存在个体及其属性,我还希望能够添加它们。 Example, adding John, his age, likes, hobbies, etc.例如,添加约翰、他的年龄、喜好、爱好等。

I'm just adding UninformedUser's comment here in a response so this can be accepted.我只是在回复中在此处添加 UninformedUser 的评论,以便可以接受。

You do just use g.update(queryString) , see the documentation here:您只需使用g.update(queryString) ,请参阅此处的文档:

https://rdflib.readthedocs.io/en/latest/intro_to_sparql.html#update-queries https://rdflib.readthedocs.io/en/latest/intro_to_sparql.html#update-queries

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM