Tracker.SparqlStatement¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w/co |
connection |
||
r/w/co |
sparql |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent_instance |
r |
Class Details¶
- class Tracker.SparqlStatement(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
TrackerSparqlStatementrepresents a prepared statement for a SPARQL query.The SPARQL query will be internally compiled into the format that is most optimal to execute the query many times. For connections created through [ctor`SparqlConnection`.new] that will be a SQLite compiled statement.
The SPARQL query may contain parameterized variables expressed via the
~prefix in the SPARQL syntax (e.g.~var), these may happen anywhere in the SPARQL where a literal or variable would typically happen. These parameterized variables may be mapped to arbitrary values prior to execution. TheTrackerSparqlStatementmay be reused for future queries with different values.The argument bindings may be changed through the [method`SparqlStatement`.bind_int], [method`SparqlStatement`.bind_int], etc… family of functions. Those functions receive a name argument corresponding for the variable name in the SPARQL query (eg.
"var"for~var) and a value to map the variable to.Once all arguments have a value, the query may be executed through [method`SparqlStatement`.execute_async] or [method`SparqlStatement`.execute].
It is possible to use any
TrackerSparqlStatementfrom other threads than the one it was created from. However, binding values and executing the statement must only happen from one thread at a time. It is possible to reuse theTrackerSparqlStatementright after [method`SparqlStatement`.execute_async] was called, there is no need to wait for [method`SparqlStatement`.execute_finish].In some circumstances, it is possible that the query needs to be recompiled from the SPARQL source. This will happen transparently.
- bind_boolean(name, value)¶
-
Binds the boolean value to the parameterized variable given by name.
- bind_datetime(name, value)¶
- Parameters:
name (
str) – variable namevalue (
GLib.DateTime) – value
Binds the [type`GLib`.DateTime] value to the parameterized variable given by name.
New in version 3.2.
- bind_double(name, value)¶
-
Binds the double value to the parameterized variable given by name.
- bind_int(name, value)¶
-
Binds the integer value to the parameterized variable given by name.
- bind_langstring(name, value, langtag)¶
-
Binds the value to the parameterized variable given by name, tagged with the language defined by langtag. The language tag should follow RFC 5646. The parameter will be represented as a rdf:langString.
New in version 3.7.
- bind_string(name, value)¶
-
Binds the string value to the parameterized variable given by name.
- clear_bindings()¶
Clears all bindings.
- execute(cancellable)¶
- Parameters:
cancellable (
Gio.CancellableorNone) – Optional [type`Gio`.Cancellable]- Raises:
- Returns:
A
TrackerSparqlCursorwith the query results.- Return type:
Executes the
SELECTorASKSPARQL query with the currently bound values.This function also works for
DESCRIBEandCONSTRUCTqueries that retrieve data from the triple store. These query forms that return RDF data are however more useful together with [method`SparqlStatement`.serialize_async].This function should only be called on
TrackerSparqlStatementobjects obtained through [method`SparqlConnection`.query_statement] or SELECT/CONSTRUCT/DESCRIBE statements loaded through [method`SparqlConnection`.load_statement_from_gresource]. An error will be raised if this method is called on aINSERTorDELETESPARQL query.
- execute_async(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.CancellableorNone) – Optional [type`Gio`.Cancellable]callback (
Gio.AsyncReadyCallbackorNone) – user-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.user_data (
objectorNone) – user-defined data to be passed to callback
Executes asynchronously the
SELECTorASKSPARQL query with the currently bound values.This function also works for
DESCRIBEandCONSTRUCTqueries that retrieve data from the triple store. These query forms that return RDF data are however more useful together with [method`SparqlStatement`.serialize_async].This function should only be called on
TrackerSparqlStatementobjects obtained through [method`SparqlConnection`.query_statement] or SELECT/CONSTRUCT/DESCRIBE statements loaded through [method`SparqlConnection`.load_statement_from_gresource]. An error will be raised if this method is called on aINSERTorDELETESPARQL query.
- execute_finish(res)¶
- Parameters:
res (
Gio.AsyncResult) – a [type`Gio`.AsyncResult] with the result of the operation- Raises:
- Returns:
A
TrackerSparqlCursorwith the query results.- Return type:
Finishes the asynchronous operation started through [method`SparqlStatement`.execute_async].
- get_connection()¶
- Returns:
The SPARQL connection of this statement.
- Return type:
Returns the [class`SparqlConnection`] that this statement was created for.
- get_sparql()¶
- Returns:
The contained SPARQL query
- Return type:
Returns the SPARQL string that this prepared statement holds.
- serialize_async(flags, format, cancellable, callback, *user_data)¶
- Parameters:
flags (
Tracker.SerializeFlags) – serialization flagsformat (
Tracker.RdfFormat) – RDF format of the serialized datacancellable (
Gio.CancellableorNone) – Optional [type`Gio`.Cancellable]callback (
Gio.AsyncReadyCallbackorNone) – user-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.user_data (
objectorNone) – user-defined data to be passed to callback
Serializes a
DESCRIBEorCONSTRUCTquery into the given RDF format.The query self was created from must be either a
DESCRIBEorCONSTRUCTquery, an error will be raised otherwise.This is an asynchronous operation, callback will be invoked when the data is available for reading.
The SPARQL endpoint may not support the specified format, in that case an error will be raised.
The flags argument is reserved for future expansions, currently
Tracker.SerializeFlags.NONEmust be passed.New in version 3.3.
- serialize_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – a [type`Gio`.AsyncResult] with the result of the operation- Raises:
- Returns:
a [class`Gio`.InputStream] to read RDF content.
- Return type:
Finishes the asynchronous operation started through [method`SparqlStatement`.serialize_async].
New in version 3.3.
- update(cancellable)¶
- Parameters:
cancellable (
Gio.CancellableorNone) – Optional [type`Gio`.Cancellable]- Raises:
- Returns:
- Return type:
Executes the
INSERT/DELETESPARQL query series with the currently bound values.This function should only be called on
TrackerSparqlStatementobjects obtained through [method`SparqlConnection`.update_statement] orINSERT/DELETEstatements loaded through [method`SparqlConnection`.load_statement_from_gresource]. An error will be raised if this method is called onSELECT/ASK/DESCRIBE/CONSTRUCTSPARQL queries.New in version 3.5.
- update_async(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.CancellableorNone) – Optional [type`Gio`.Cancellable]callback (
Gio.AsyncReadyCallbackorNone) – user-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.user_data (
objectorNone) – user-defined data to be passed to callback
Executes asynchronously the
INSERT/DELETESPARQL query series with the currently bound values.This function should only be called on
TrackerSparqlStatementobjects obtained through [method`SparqlConnection`.update_statement] orINSERT/DELETEstatements loaded through [method`SparqlConnection`.load_statement_from_gresource]. An error will be raised if this method is called onSELECT/ASK/DESCRIBE/CONSTRUCTSPARQL queries.New in version 3.5.
- update_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – a [type`Gio`.AsyncResult] with the result of the operation- Raises:
- Returns:
- Return type:
Finishes the asynchronous update started through [method`SparqlStatement`.update_async].
New in version 3.5.
Property Details¶
- Tracker.SparqlStatement.props.connection¶
- Name:
connection- Type:
- Default Value:
- Flags:
The [class`SparqlConnection`] the statement was created for.