RDFLib / sparqlwrapper

A wrapper for a remote SPARQL endpoint
https://sparqlwrapper.readthedocs.io/
Other
520 stars 123 forks source link

Unable to send a triples in Blazegraph #91

Closed Gautamshahi closed 6 years ago

Gautamshahi commented 6 years ago

I am using the below mentioned code to send the triples in the blazegraph

from SPARQLWrapper import SPARQLWrapper, JSON from rdflib import Graph, URIRef, Literal sparql = SPARQLWrapper("http://141.26.67.20:9999/blazegraph/sparql") uri = 'http://www.eluniverso.com/tema/copa-libertadores-1' g = Graph() result = g.parse(uri, format='rdfa') s = g.serialize(format='nt') triples = (s)

triples = ''

queryString = (""" INSERT DATA {{ GRAPH {} {{ {} }} }} """).format(uri, triples) sparql.setQuery(queryString) sparql.method = 'POST' try : ret = sparql.query() except Exception as err:
print(err.message)
pass

The variable s contains statement like http://www.eluniverso.com/futbol-internacional http://www.w3.org/2004/02/skos/core#prefLabel "F\u00FAtbol Internacional"@es . http://www.eluniverso.com/futbol http://www.w3.org/2004/02/skos/core#prefLabel "F\u00FAtbol"@es . http://www.eluniverso.com/sites/default/files/styles/pagina_temas_180x135/public/fotos/2017/09/data19531443.jpg?itok=tlcyoz4z http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://xmlns.com/foaf/0.1/Image . http://www.eluniverso.com/tema/copa-libertadores-1 http://ogp.me/ns/fb#admins "100000069041809"@es .

But I am getting the below error, Kindly suggest the possible solution

image

dayures commented 6 years ago

Maybe the issue is that the GRAPH URI is not between "<>"

So, instead of GRAPH http://www.eluniverso.com/tema/copa-libertadores-1 should be GRAPH <http://www.eluniverso.com/tema/copa-libertadores-1>

Gautamshahi commented 6 years ago

Thank you for the suggestion, yes I found it.

On Tue, Oct 10, 2017 at 7:05 PM, dayures notifications@github.com wrote:

Maybe the issue is that the GRAPH URI is not between "<>"

So, instead of GRAPH http://www.eluniverso.com/tema/copa-libertadores-1 should be GRAPH http://www.eluniverso.com/tema/copa-libertadores-1

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RDFLib/sparqlwrapper/issues/91#issuecomment-335474391, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyFFsAmLWB2pMSJtVr1SwhQyWAg89vUks5sq3K-gaJpZM4Pz2-F .

-- Gautam Kishore Shahi, Master Student, DISI- University of Trento, Italy