This is a wrapper around a SPARQL service. It helps in creating the query URI and, possibly,
convert the result into a more manageable format. The package is licensed under
W3C license,
and it can be downloaded in .zip and .tar.gz formats
from SourceForge
(also from PyPi or
from Debian).
The following packages are used:
These packages are imported in a lazy fashion, ie, only when needed.
Ie, if the user never intends to use the JSON format, the
simplejson package is not imported and the user does not
have to install it.
Developers involved:
Here you have an example of how to use the library in your python program:
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setQuery("""
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?label
WHERE { <http://dbpedia.org/resource/Asturias> rdfs:label ?label }
""")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
for result in results["results"]["bindings"]:
print result["label"]["value"]
You can also read online documentation for more information, or contact us in the development mailing list (archives are public).