Package SPARQL :: Module Results :: Class SPARQLWrapper2
[hide private]
[frames] | no frames]

Class SPARQLWrapper2

source code

Wrapper.SPARQLWrapper --+
                        |
                       SPARQLWrapper2

Subclass of Wrapper that works with a JSON return result only. The query result is automaticall set to a Results instance. Makes the standard query processing a bit simpler

Instance Methods [hide private]
 
__init__(self, baseURI, defaultGraph=None)
Class encapsulating a full SPARQL call.
source code
 
setReturnFormat(self, format)
Set the return format.
source code
Python dictionary
convertJSON(self, queryResult)
Convert a JSON result into a Python dict and then creates a Results instance
source code
Results instance
query(self)
Execute the query.
source code

Inherited from Wrapper.SPARQLWrapper: addDefaultGraph, addExtraURITag, addNamedGraph, convert, convertRDF, convertXML, getURI, queryAndConvert, setQuery

Method Details [hide private]

__init__(self, baseURI, defaultGraph=None)
(Constructor)

source code 
Class encapsulating a full SPARQL call. In contrast to the SPARQL.SPARQLWrapper superclass, the return format cannot be set (it is defaulted to JSON)
Parameters:
  • baseURI (string) - string of the SPARQL endpoint's URI
  • defaultGraph (string) - URI for the default graph. Default is None, can be set via an explicit call, too
Overrides: Wrapper.SPARQLWrapper.__init__

setReturnFormat(self, format)

source code 
Set the return format. This method is doing nothing; this class instance should work with JSON only!
Overrides: Wrapper.SPARQLWrapper.setReturnFormat

convertJSON(self, queryResult)

source code 
Convert a JSON result into a Python dict and then creates a Results instance
Parameters:
  • queryResult - result of a (previous) query
Returns: Python dictionary
converted result
Overrides: Wrapper.SPARQLWrapper.convertJSON

query(self)

source code 
Execute the query. Exceptions can be raised if either the URI is wrong or the HTTP sends back an error. The usual urllib2 exceptions are raised, which cover possible SPARQL errors, too
Returns: Results instance
query result
Overrides: Wrapper.SPARQLWrapper.query