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:
TrackerSparqlStatement
represents 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`Tracker`.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. TheTrackerSparqlStatement
may be reused for future queries with different values.The argument bindings may be changed through the [method`Tracker`.SparqlStatement.bind_int], [method`Tracker`.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`Tracker`.SparqlStatement.execute_async] or [method`Tracker`.SparqlStatement.execute].
It is possible to use any
TrackerSparqlStatement
from 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 theTrackerSparqlStatement
right after [method`Tracker`.SparqlStatement.execute_async] was called, there is no need to wait for [method`Tracker`.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.Cancellable
orNone
) – Optional [type`Gio`.Cancellable]- Raises:
- Returns:
A
TrackerSparqlCursor
with the query results.- Return type:
Executes the
SELECT
orASK
SPARQL query with the currently bound values.This function also works for
DESCRIBE
andCONSTRUCT
queries that retrieve data from the triple store. These query forms that return RDF data are however more useful together with [method`Tracker`.SparqlStatement.serialize_async].This function should only be called on
TrackerSparqlStatement
objects obtained through [method`Tracker`.SparqlConnection.query_statement] or SELECT/CONSTRUCT/DESCRIBE statements loaded through [method`Tracker`.SparqlConnection.load_statement_from_gresource]. An error will be raised if this method is called on aINSERT
orDELETE
SPARQL query.
- execute_async(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – Optional [type`Gio`.Cancellable]callback (
Gio.AsyncReadyCallback
orNone
) – user-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.user_data (
object
orNone
) – user-defined data to be passed to callback
Executes asynchronously the
SELECT
orASK
SPARQL query with the currently bound values.This function also works for
DESCRIBE
andCONSTRUCT
queries that retrieve data from the triple store. These query forms that return RDF data are however more useful together with [method`Tracker`.SparqlStatement.serialize_async].This function should only be called on
TrackerSparqlStatement
objects obtained through [method`Tracker`.SparqlConnection.query_statement] or SELECT/CONSTRUCT/DESCRIBE statements loaded through [method`Tracker`.SparqlConnection.load_statement_from_gresource]. An error will be raised if this method is called on aINSERT
orDELETE
SPARQL query.
- execute_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – a [type`Gio`.AsyncResult] with the result of the operation- Raises:
- Returns:
A
TrackerSparqlCursor
with the query results.- Return type:
Finishes the asynchronous operation started through [method`Tracker`.SparqlStatement.execute_async].
- get_connection()¶
- Returns:
The SPARQL connection of this statement.
- Return type:
Returns the [class`Tracker`.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.Cancellable
orNone
) – Optional [type`Gio`.Cancellable]callback (
Gio.AsyncReadyCallback
orNone
) – user-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.user_data (
object
orNone
) – user-defined data to be passed to callback
Serializes a
DESCRIBE
orCONSTRUCT
query into the given RDF format.The query self was created from must be either a
DESCRIBE
orCONSTRUCT
query, 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.NONE
must 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`Tracker`.SparqlStatement.serialize_async].
New in version 3.3.
- update(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – Optional [type`Gio`.Cancellable]- Raises:
- Returns:
- Return type:
Executes the
INSERT
/DELETE
SPARQL query series with the currently bound values.This function should only be called on
TrackerSparqlStatement
objects obtained through [method`Tracker`.SparqlConnection.update_statement] orINSERT
/DELETE
statements loaded through [method`Tracker`.SparqlConnection.load_statement_from_gresource]. An error will be raised if this method is called onSELECT
/ASK
/DESCRIBE
/CONSTRUCT
SPARQL queries.New in version 3.5.
- update_async(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – Optional [type`Gio`.Cancellable]callback (
Gio.AsyncReadyCallback
orNone
) – user-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.user_data (
object
orNone
) – user-defined data to be passed to callback
Executes asynchronously the
INSERT
/DELETE
SPARQL query series with the currently bound values.This function should only be called on
TrackerSparqlStatement
objects obtained through [method`Tracker`.SparqlConnection.update_statement] orINSERT
/DELETE
statements loaded through [method`Tracker`.SparqlConnection.load_statement_from_gresource]. An error will be raised if this method is called onSELECT
/ASK
/DESCRIBE
/CONSTRUCT
SPARQL 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`Tracker`.SparqlStatement.update_async].
New in version 3.5.
Property Details¶
- Tracker.SparqlStatement.props.connection¶
- Name:
connection
- Type:
- Default Value:
- Flags:
The [class`Tracker`.SparqlConnection] the statement was created for.