SparqlModel Class Reference
from PyKDE4.soprano import *
Inherits: Soprano.Model → QObject
Namespace: Soprano::Client
Detailed Description
\class SparqlModel sparqlmodel.h Soprano/Client/SparqlModel
Remote client Model for Http SPARQL end points.
The SparqlModel provides a very simple way of accessing remote SPARQL (SPARQL Protocol and RDF Query Language) web services via Http.
Its usage is simple: set hostname and optionally user credentials, then call the well known Model methods like Model.executeQuery to work with the remote repository.
- Since:
- 2.2
| Methods | |
| __init__ (self, QString host=QString(), int port=80, QString user=QString(), QString password=QString()) | |
| Soprano.Error.ErrorCode | addStatement (self, Soprano.Statement statement) | 
| bool | containsAnyStatement (self, Soprano.Statement statement) | 
| bool | containsStatement (self, Soprano.Statement statement) | 
| Soprano.Node | createBlankNode (self) | 
| Soprano.QueryResultIterator | executeQuery (self, QString query, Soprano.Query.QueryLanguage language=Query.QueryLanguageSparql, QString userQueryLanguage=QString()) | 
| Soprano.Util.AsyncResult | executeQueryAsync (self, QString query, Soprano.Query.QueryLanguage language=Query.QueryLanguageSparql, QString userQueryLanguage=QString()) | 
| bool | isEmpty (self) | 
| Soprano.NodeIterator | listContexts (self) | 
| Soprano.StatementIterator | listStatements (self, Soprano.Statement partial) | 
| Soprano.Error.ErrorCode | removeAllStatements (self, Soprano.Statement statement) | 
| Soprano.Error.ErrorCode | removeStatement (self, Soprano.Statement statement) | 
| setHost (self, QString host, int port=80) | |
| setPath (self, QString path) | |
| setUser (self, QString user, QString password=QString()) | |
| int | statementCount (self) | 
Method Documentation
| __init__ | ( | self, | ||
| QString | host=QString(), | |||
| int | port=80, | |||
| QString | user=QString(), | |||
| QString | password=QString() | |||
| ) | 
Create a new SparqlModel instance.
- Parameters:
- 
host The host to connect to (example: dbpedia.org) 
- Parameters:
- 
port The port on which to connect the host (most Http services run on port 80. 
- Parameters:
- 
user The userName in case the host does not allow anonymous access. 
- Parameters:
- 
password The password for user in case the host does not allow anonymous access. 
| Soprano.Error.ErrorCode addStatement | ( | self, | ||
| Soprano.Statement | statement | |||
| ) | 
Add a statement to the remote model.
This method is realized using the SPARQL/Update language extension. Thus, it will only work on services supporting this extension.
- Parameters:
- 
statement The Statement to add. 
- Returns:
- Error.ErrorNone on success and an error code if statement was invalid or an error occured. Check Error.ErrorCache.lastError for detailed error information.
| bool containsAnyStatement | ( | self, | ||
| Soprano.Statement | statement | |||
| ) | 
| bool containsStatement | ( | self, | ||
| Soprano.Statement | statement | |||
| ) | 
| Soprano.Node createBlankNode | ( | self ) | 
Creation of blank nodes is not supported by the SparqlModel.
- Returns:
- an invalid Node
| Soprano.QueryResultIterator executeQuery | ( | self, | ||
| QString | query, | |||
| Soprano.Query.QueryLanguage | language=Query.QueryLanguageSparql, | |||
| QString | userQueryLanguage=QString() | |||
| ) | 
Execute a query on the SPARQL endpoint.
- Parameters:
- 
query The query to evaluate. 
- Parameters:
- 
language The query language used to encode query. Be aware that the SparqlModel does only support one query language: Query.QueryLanguageSparql. 
- Parameters:
- 
userQueryLanguage unused since language needs to be set to Query.QueryLanguageSparql. 
- Returns:
- An iterator over all results matching the query, on error an invalid iterator is returned.
| Soprano.Util.AsyncResult executeQueryAsync | ( | self, | ||
| QString | query, | |||
| Soprano.Query.QueryLanguage | language=Query.QueryLanguageSparql, | |||
| QString | userQueryLanguage=QString() | |||
| ) | 
Asyncroneously execute the given query over the Model.
- Parameters:
- 
query The query to evaluate. 
- Parameters:
- 
language The %query language used to encode query. 
- Parameters:
- 
userQueryLanguage If language equals Query.QueryLanguageUser userQueryLanguage defines the language to use. 
\sa executeQuery
- Returns:
- an AsyncResult with result type QueryResultIterator object which will signal when the result is ready.
| bool isEmpty | ( | self ) | 
Not supported by the SparqlModel.
- Returns:
- false
| Soprano.NodeIterator listContexts | ( | self ) | 
| Soprano.StatementIterator listStatements | ( | self, | ||
| Soprano.Statement | partial | |||
| ) | 
| Soprano.Error.ErrorCode removeAllStatements | ( | self, | ||
| Soprano.Statement | statement | |||
| ) | 
Remove all statements that match the partial statement. For removing one specific statement see removeStatement().
This method is realized using the SPARQL/Update language extension. Thus, it will only work on services supporting this extension.
- Parameters:
- 
statement A possible partially defined statement that serves as a filter for all statements that should be removed. 
- Returns:
- Error.ErrorNone on success and an error code if statement was invalid or an error occured. Check Error.ErrorCache.lastError for detailed error information.
| Soprano.Error.ErrorCode removeStatement | ( | self, | ||
| Soprano.Statement | statement | |||
| ) | 
Removed a statement from the remote model.
This method is realized using the SPARQL/Update language extension. Thus, it will only work on services supporting this extension.
- Parameters:
- 
statement The Statement to remove. 
- Returns:
- Error.ErrorNone on success and an error code if statement was invalid or an error occured. Check Error.ErrorCache.lastError for detailed error information.
| setHost | ( | self, | ||
| QString | host, | |||
| int | port=80 | |||
| ) | 
Set the host to connect to.
- Parameters:
- 
host The host to connect to (example: dbpedia.org) 
- Parameters:
- 
port The port on which to connect the host (most Http services run on port 80. 
| setPath | ( | self, | ||
| QString | path | |||
| ) | 
Set the path to where the SPARQL endpoint is exposed on the server.
For historical reasons the default path is set to "/sparql".
- Since:
- 2.2.1
Set the user name and password to access the host.
- Parameters:
- 
user The userName in case the host does not allow anonymous access. 
- Parameters:
- 
password The password for user in case the host 
| int statementCount | ( | self ) | 
Retrieving the number of statements is not supported by the SparqlModel.
- Returns:
- -1
 KDE 4.3 PyKDE API Reference
        KDE 4.3 PyKDE API Reference