Package SPARQLWrapper :: Module SmartWrapper :: Class SPARQLWrapper2
[hide private]
[frames] | no frames]

Class SPARQLWrapper2

source code

           object --+    
                    |    
Wrapper.SPARQLWrapper --+
                        |
                       SPARQLWrapper2

Subclass of Wrapper that works with a JSON SELECT return result only. The query result is automatically set to a Bindings instance. Makes the average 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 (overriding the inherited method).
source code
Bindings instance
query(self)
Execute the query and do an automatic conversion.
source code
 
queryAndConvert(self)
This is here to override the inherited method; it is equivalent to query.
source code

Inherited from Wrapper.SPARQLWrapper: addCustomParameter, addDefaultGraph, addExtraURITag, addNamedGraph, addParameter, clearParameter, isSparqlQueryRequest, isSparqlUpdateRequest, resetQuery, setCredentials, setHTTPAuth, setMethod, setQuery, setRequestMethod, setTimeout, setUseKeepAlive, supportsReturnFormat

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from Wrapper.SPARQLWrapper: pattern

Instance Variables [hide private]

Inherited from Wrapper.SPARQLWrapper: baseURI

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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

source code 

Class encapsulating a full SPARQL call. In contrast to the 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: object.__init__

setReturnFormat(self, format)

source code 

Set the return format (overriding the inherited method). This method does nothing; this class instance should work with JSON only. The method is defined just to avoid possible errors by erronously setting the return format. When using this class, the user can safely ignore this call.

Parameters:
  • format - return format
Overrides: Wrapper.SPARQLWrapper.setReturnFormat

query(self)

source code 

Execute the query and do an automatic conversion.

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.

If the query type is not SELECT, the method falls back to the corresponding method in the superclass.

Returns: Bindings instance
query result
Overrides: Wrapper.SPARQLWrapper.query

queryAndConvert(self)

source code 

This is here to override the inherited method; it is equivalent to query.

If the query type is not SELECT, the method falls back to the corresponding method in the superclass.

Returns:
the converted query result.
Overrides: Wrapper.SPARQLWrapper.queryAndConvert