Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I insert variable into SPARQL query?

I use the rdflib library. I need to insert a variable into a SPARQL query.

I do this:

q = prepareUpdate("""INSERT DATA { <r> a <owl:Ontology> }""")
g.update(q, initBindings={'r': uri})
uri = 'http://www.example.org/ontologies/example/example.owl'
g - object class Graph()

Output result: <r:> a <owl:Ontology> .

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Required result: <http://www.example.org/ontologies/example/example.owl> a <owl:Ontology> .

>Solution :

use


q = prepareUpdate("""INSERT DATA { <%s> a <owl:Ontology> }""" % uri)
g.update(q)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading