irina_ikonn
irina_ikonn

Reputation: 91

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> .

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

Upvotes: 0

Views: 172

Answers (1)

Elvin Jafarov
Elvin Jafarov

Reputation: 1467

use


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

Upvotes: 2

Related Questions