Home | Trees | Indices | Help |
|
---|
|
object --+ | SPARQLWrapper
Wrapper around an online access to a SPARQL Web entry point.
The same class instance can be reused for subsequent queries. The values of the base Graph URI, return formats, etc, are retained from one query to the next (in other words, only the query string changes). The instance can also be reset to its initial values using the resetQuery method.
|
|||
|
|||
|
|||
|
|||
bool |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
bool |
|
||
bool |
|
||
|
|||
bool |
|
||
bool |
|
||
|
|||
|
|||
|
|||
string |
|
||
|
|||
|
|||
bool |
|
||
bool |
|
||
string |
|
||
string |
|
||
|
|||
|
|||
|
|||
QueryResult instance |
|
||
|
|||
string |
|
||
Inherited from |
|
|||
compiled regular expression (see the re module of
Python)
|
prefix_pattern = re.compile(r' regular expression used to remove base/prefixes in the process of determining the query type. |
||
compiled regular expression (see the re module of
Python)
|
pattern = re.compile(r' regular expression used to determine whether a query (without base/prefixes) is of type CONSTRUCT, SELECT, ASK, DESCRIBE, INSERT, DELETE, CREATE, CLEAR, DROP, LOAD, COPY, MOVE or ADD. |
||
compiled regular expression (see the re module of
Python)
|
comments_pattern = re.compile(r' regular expression used to remove comments from a query. |
|
|||
string |
_defaultGraph URI for the default graph. |
||
string |
_defaultReturnFormat The default return format. |
||
string |
agent The User-Agent for the HTTP request header. |
||
dict |
customHttpHeaders Custom HTTP Headers to be included in the request. |
||
string |
endpoint SPARQL endpoint's URI. |
||
string |
http_auth HTTP Authentication type. |
||
string |
method The invocation method. |
||
boolean |
onlyConneg Option for allowing (or not) only HTTP Content Negotiation (so dismiss the use of HTTP parameters).The default value is False .
|
||
dict |
parameters The parameters of the request (key/value pairs in a dictionary). |
||
string |
passwd The password of the credentials for querying the current endpoint. |
||
string |
queryString The SPARQL query text. |
||
string |
queryType The type of SPARQL query (aka SPARQL query form), like CONSTRUCT, SELECT, ASK, DESCRIBE, INSERT, DELETE, CREATE, CLEAR, DROP, LOAD, COPY, MOVE or ADD (constants in this module). |
||
string |
requestMethod The request method for query or update operations. |
||
string |
returnFormat The return format. |
||
int |
timeout The timeout (in seconds) to use for querying the endpoint. |
||
string |
updateEndpoint SPARQL endpoint's URI for update operations (if it's a different one). |
||
string |
user The username of the credentials for querying the current endpoint. |
|
|||
Inherited from |
|
Class encapsulating a full SPARQL call.
|
Set the return format. If not an allowed value, the setting is ignored. |
Check if a return format is supported. |
Set the timeout (in seconds) to use for querying the endpoint.
|
Set this option for allowing (or not) only HTTP Content Negotiation (so dismiss the use of HTTP parameters).
Since: 1.8.1 |
Set the internal method to use to perform the request for query or update operations, either URL-encoded (SPARQLWrapper.URLENCODED) or POST directly (SPARQLWrapper.POSTDIRECTLY). Further details at http://www.w3.org/TR/sparql11-protocol/#query-operation and http://www.w3.org/TR/sparql11-protocol/#update-operation.
|
Add a default graph URI.
Deprecated: use addParameter("default-graph-uri", uri) instead of this method |
Add a named graph URI.
Deprecated: use addParameter("named-graph-uri", uri) instead of this method |
Some SPARQL endpoints require extra key value pairs. E.g., in
virtuoso, one would add
Deprecated: use addParameter(key, value) instead of this method |
Method is kept for backwards compatibility. Historically, it "replaces" parameters instead of adding.
Deprecated: use addParameter(name, value) instead of this method |
Some SPARQL endpoints allow extra key value pairs. E.g., in virtuoso,
one would add
|
Add a custom HTTP header (this method can override all HTTP headers).
IMPORTANT: Take into acount that each previous value for the header field
names
Since: 1.8.2 |
Clear the values of a custom Http Header previously setted. Returns a boolean indicating if the clearing has been accomplished.
Since: 1.8.2 |
Clear the values of a concrete parameter. Returns a boolean indicating if the clearing has been accomplished.
|
Set the credentials for querying the current endpoint.
Change Log:
Added |
Set the HTTP Authentication type. Possible values are BASIC or DIGEST. |
Set the SPARQL query text. Note: no check is done on the validity of the query (syntax or otherwise) by this module, except for testing the query type (SELECT, ASK, etc). Syntax and validity checking is done by the SPARQL service itself.
|
Internal method for parsing the SPARQL query and return its type (ie, SELECT, ASK, etc). Note that the method returns SELECT if nothing is specified. This is just to get all other methods running; in fact, this means that the query is erroneous, because the query must be, according to the SPARQL specification, one of Select, Ask, Describe, or Construct. The SPARQL endpoint should raise an exception (via urllib) for such syntax error.
|
Set the invocation method. By default, this is GET, but can be set to POST. |
Make urllib2 use keep-alive.
|
Returns
|
Returns
|
Internal method for returning the query after all occurrence of singleline comments are removed (issues #32 and #77).
|
Internal method for getting the request encoded parameters.
|
Internal method for getting the HTTP Accept Header. |
Internal method to create request according a HTTP method. Returns a
|
Internal method to execute the query. Returns the output of the
|
Execute the query. Exceptions can be raised if either the URI is wrong or the HTTP sends back an error (this is also the case when the query is syntactically incorrect, leading to an HTTP error sent back by the SPARQL endpoint). The usual urllib2 exceptions are raised, which therefore cover possible SPARQL errors, too. Note that some combinations of return formats and query types may not make sense. For example, a SELECT query with Turtle response is meaningless (the output of a SELECT is not a Graph), or a CONSTRUCT query with JSON output may be a problem because, at the moment, there is no accepted JSON serialization of RDF (let alone one implemented by SPARQL endpoints). In such cases the returned media type of the result is unpredictable and may differ from one SPARQL endpoint implementation to the other. (Endpoints usually fall back to one of the "meaningful" formats, but it is up to the specific implementation to choose which one that is.)
|
Macro like method: issue a query and return the converted results.
|
This method returns the string representation of a SPARQLWrapper object.
Since: 1.8.3 |
|
prefix_patternregular expression used to remove base/prefixes in the process of determining the query type.
|
patternregular expression used to determine whether a query (without base/prefixes) is of type CONSTRUCT, SELECT, ASK, DESCRIBE, INSERT, DELETE, CREATE, CLEAR, DROP, LOAD, COPY, MOVE or ADD.
|
|
_defaultGraphURI for the default graph. Default isNone , the value can be
set either via an explicit call("default-graph-uri", uri) or as
part of the query string.
|
customHttpHeadersCustom HTTP Headers to be included in the request. Important: These headers override previous values (includingContent-Type ,
User-Agent , Accept and
Authorization if they are present). It is a dictionary where
keys are the header field nada and values are the header values.
|
http_authHTTP Authentication type. The default value is BASIC. Possible values are BASIC or DIGEST
|
passwdThe password of the credentials for querying the current endpoint. Default isNone , the value can be set an explicit call.
|
requestMethodThe request method for query or update operations. The possibles values are URL-encoded (URLENCODED) or POST directly (POSTDIRECTLY).
|
returnFormatThe return format. The possible values are JSON, XML, TURTLE, N3, RDF, RDFXML, CSV, TSV, JSONLD (constants in this module).
|
updateEndpointSPARQL endpoint's URI for update operations (if it's a different one). Default isNone
|
userThe username of the credentials for querying the current endpoint. Default isNone , the value can be set an explicit call.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Apr 18 09:55:03 2019 | http://epydoc.sourceforge.net |