Sparql Insert Exception : Sparqlwrapper.sparqlexceptions.querybadformed
Solution 1:
If you take this to the sparql.org's SPARQL update validator, it will tell you immediately that this is wrong, and where the syntax error is:
Input:
1 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 2 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 3 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 4 PREFIX owl: <http://www.w3.org/2002/07/owl#> 5 PREFIX fn: <http://www.w3.org/2005/xpath-functions#> 6 PREFIX apf: <http://jena.hpl.hp.com/ARQ/property#> 7 8 PREFIX dbpedia: <http://dbpedia.org/resource/> 9 Insert Data Into GRAPH <test> { 10 <http://dbpedia.org/resource/life> <http://umbel.org/umbel/rc/Artist> '2'^^xsd:integer . 11 }
Syntax error:
Encountered " "into" "Into "" at line 9, column 13. Was expecting: "{" ...
Of course, to find out how to do what you're trying to do, you'll need to look to the spec. The SPARQL 1.1 Update is the place to look, and while I'd advise you to skim through that to get a good idea of what's in there, one example will be enough to show what you need to write:
Example 2:
This SPARQL 1.1 Update request adds a triple to provide the price of a book. As opposed to the previous example, which affected the default graph, the requested change happens in the named graph identified by the IRI
http://example/bookStore
.PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX ns: <http://example.org/ns#> INSERT DATA { GRAPH <http://example/bookStore> { <http://example/book1> ns:price 42 } }
Your query needs to be
PREFIX dbpedia: <http://dbpedia.org/resource/>
Insert Data
{ GRAPH <test> { <http://dbpedia.org/resource/life> <http://umbel.org/umbel/rc/Artist> '2'^^xsd:integer . } }
Solution 2:
I spent all day battling this problem. I finally found the solution to my version of this problem:
Make sure that your spaces are actually spaces and not just newlines "\n". The editors have no problem with this, SPARQLWrapper doesn't like it.
Post a Comment for "Sparql Insert Exception : Sparqlwrapper.sparqlexceptions.querybadformed"