Running sparqlwrapper package using fuseki

15 views
Skip to first unread message

cvsrso...@gmail.com

unread,
Sep 10, 2018, 10:32:43 PM9/10/18
to rdflib-dev
I'm trying to implement a sparqlwrapper class in python by using Flask and I'm getting a server error 500 while doing so. In the fuseki command line it's showing the 400 parse error.

Below is the code that I used to execute the query(I don't know whether it is correct or not but just tried to implement it).

Can anyone tell me whether this code is right or not and the corrections if possible.

from flask import Flask
from SPARQLWrapper import SPARQLWrapper, JSON
app = Flask(__name__)

@app.route('/')
def hello_world():
sparql = SPARQLWrapper("http://localhost:3030/BookMashup/sparql")
sparql.setQuery("""
PREFIX rdfs: <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
SELECT ?label
WHERE { <http://dbpedia.org/resource/120_Days_of_Sodom> }
""")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()

for result in results["results"]["bindings"]:
print(result["label"]["value"])

Sergio Fernández

unread,
Sep 10, 2018, 11:55:37 PM9/10/18
to rdfli...@googlegroups.com
That you're proxying in a Flask app the SPARQl query I think is not relevant for the issue.


Because I think you're pointing to the wrong endpoint. I think it should be something like /ds/query




--
http://github.com/RDFLib
---
You received this message because you are subscribed to the Google Groups "rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rdflib-dev+...@googlegroups.com.
To post to this group, send email to rdfli...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rdflib-dev/4cc0c4a5-47f1-4c9a-ad95-3477687430bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ram Somesh Chittella

unread,
Sep 11, 2018, 12:04:52 AM9/11/18
to rdfli...@googlegroups.com
Can you tell me how the endpoint should be? 

You received this message because you are subscribed to a topic in the Google Groups "rdflib-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rdflib-dev/tVZJcyNIGNI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rdflib-dev+...@googlegroups.com.

To post to this group, send email to rdfli...@googlegroups.com.

Sergio Fernández

unread,
Sep 11, 2018, 11:11:20 AM9/11/18
to rdfli...@googlegroups.com
I haven't use Fuseki for a while. But check the documentation I've linked in my previous email. I think it should be:


(so replacing 'ds' by your dataset name)


Osma Suominen

unread,
Sep 12, 2018, 5:22:50 AM9/12/18
to rdfli...@googlegroups.com
Hello,

I think you have a syntax error in the query. The WHERE clause contains
only a single URI, not a triple pattern. I suggest you test the query
first in the Fuseki UI.

You probably need a WHERE clause like this:

WHERE {
<http://dbpedia.org/resource/120_Days_of_Sodom> rdfs:label ?label
}

-Osma
--
Osma Suominen
D.Sc. (Tech), Information Systems Specialist
National Library of Finland
P.O. Box 26 (Kaikukatu 4)
00014 HELSINGIN YLIOPISTO
Tel. +358 50 3199529
osma.s...@helsinki.fi
http://www.nationallibrary.fi
Reply all
Reply to author
Forward
0 new messages