Tracker.SparqlConnection

g GObject.Object GObject.Object Tracker.SparqlConnection Tracker.SparqlConnection GObject.Object->Tracker.SparqlConnection

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

bus_new (service_name, object_path, dbus_connection)

class

bus_new_async (service_name, object_path, dbus_connection, cancellable, callback, *user_data)

class

bus_new_finish (result)

class

new (flags, store, ontology, cancellable)

class

new_async (flags, store, ontology, cancellable, callback, *user_data)

class

new_finish (result)

class

remote_new (uri_base)

close ()

close_async (cancellable, callback, *user_data)

close_finish (res)

create_batch ()

create_notifier ()

deserialize_async (flags, format, default_graph, stream, cancellable, callback, *user_data)

deserialize_finish (result)

get_namespace_manager ()

load_statement_from_gresource (resource_path, cancellable)

map_connection (handle_name, service_connection)

query (sparql, cancellable)

query_async (sparql, cancellable, callback, *user_data)

query_finish (res)

query_statement (sparql, cancellable)

serialize_async (flags, format, query, cancellable, callback, *user_data)

serialize_finish (result)

update (sparql, cancellable)

update_array_async (sparql, sparql_length, cancellable, callback, *user_data)

update_array_finish (res)

update_async (sparql, cancellable, callback, *user_data)

update_blank (sparql, cancellable)

update_blank_async (sparql, cancellable, callback, *user_data)

update_blank_finish (res)

update_finish (res)

update_resource (graph, resource, cancellable)

update_resource_async (graph, resource, cancellable, callback, *user_data)

update_resource_finish (res)

update_statement (sparql, cancellable)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Tracker.SparqlConnection(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

Tracker.SparqlConnectionClass

TrackerSparqlConnection holds a connection to a RDF triple store.

This triple store may be of three types:

  • Local to the process, created through [ctor`Tracker`.SparqlConnection.new].

  • A HTTP SPARQL endpoint over the network, created through [ctor`Tracker`.SparqlConnection.remote_new]

  • A DBus SPARQL endpoint owned by another process in the same machine, created through [ctor`Tracker`.SparqlConnection.bus_new]

When creating a local triple store, it is required to give details about its structure. This is done by passing a location to an ontology, see more on how are ontologies defined. A local database may be stored in a filesystem location, or it may reside in memory.

A TrackerSparqlConnection is private to the calling process, it can be exposed to other hosts/processes via a [class`Tracker`.Endpoint], see [ctor`Tracker`.EndpointDBus.new] and [ctor`Tracker`.EndpointHttp.new].

When issuing SPARQL queries and updates, it is recommended that these are created through [class`Tracker`.SparqlStatement] to avoid the SPARQL injection class of bugs, see [method`Tracker`.SparqlConnection.query_statement] and [method`Tracker`.SparqlConnection.update_statement]. For SPARQL updates it is also possible to use a “builder” approach to generate RDF data, see [class`Tracker`.Resource]. It is also possible to create [class`Tracker`.SparqlStatement] objects for SPARQL queries and updates from SPARQL strings embedded in a [struct`Gio`.Resource], see [method`Tracker`.SparqlConnection.load_statement_from_gresource].

To get the best performance, it is recommended that SPARQL updates are clustered through [class`Tracker`.Batch].

TrackerSparqlConnection also offers a number of methods for the simple cases, [method`Tracker`.SparqlConnection.query] may be used when there is a SPARQL query string directly available, and the [method`Tracker`.SparqlConnection.update] family of functions may be used for one-off updates. All functions have asynchronous variants.

When a SPARQL query is executed, a [class`Tracker`.SparqlCursor] will be obtained to iterate over the query results.

Depending on the ontology definition, TrackerSparqlConnection may emit notifications whenever resources of certain types get insert, modified or deleted from the triple store (see nrl:notify. These notifications can be handled via a [class`Tracker`.Notifier] obtained with [method`Tracker`.SparqlConnection.create_notifier].

After done with a connection, it is recommended to call [method`Tracker`.SparqlConnection.close] or [method`Tracker`.SparqlConnection.close_async] explicitly to cleanly close the connection and prevent consistency checks on future runs. The triple store connection will be implicitly closed when the TrackerSparqlConnection object is disposed.

A TrackerSparqlConnection may be used from multiple threads, asynchronous updates are executed sequentially on arrival order, asynchronous queries are dispatched in a thread pool.

If you ever have the need to procedurally compose SPARQL query strings, consider the use of [func`Tracker`.sparql_escape_string] for literal strings and the [func`Tracker`.sparql_escape_uri] family of functions for URIs.

classmethod bus_new(service_name, object_path, dbus_connection)
Parameters:
  • service_name (str) –

  • object_path (str or None) – The path to the object, or None to use the default.

  • dbus_connection (Gio.DBusConnection or None) – The [type`Gio`.DBusConnection] to use, or None to use the session bus

Raises:

GLib.Error

Returns:

a new TrackerSparqlConnection.

Return type:

Tracker.SparqlConnection

service_name (nullable): The name of the D-Bus service to connect to, or None if not using a message bus. Connects to a database owned by another process on the local machine via DBus.

When using a message bus (session/system), the service_name argument will be used to describe the remote endpoint, either by unique or well-known D-Bus names. If not using a message bus (e.g. peer-to-peer D-Bus connections) the service_name may be None.

The D-Bus object path of the remote endpoint will be given through object_path, None may be used to use the default /org/freedesktop/Tracker3/Endpoint path.

The D-Bus connection used to set up the connection may be given through the dbus_connection argument. Using None will resort to the default session bus.

classmethod bus_new_async(service_name, object_path, dbus_connection, cancellable, callback, *user_data)
Parameters:
  • service_name (str) – The name of the D-Bus service to connect to.

  • object_path (str or None) – The path to the object, or None to use the default.

  • dbus_connection (Gio.DBusConnection or None) – The [class`Gio`.DBusConnection] to use, or None to use the session bus

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

  • callback (Gio.AsyncReadyCallback or None) – User-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.

  • user_data (object or None) – User-defined data to be passed to callback

Connects asynchronously to a database owned by another process on the local machine via DBus.

New in version 3.1.

classmethod bus_new_finish(result)
Parameters:

result (Gio.AsyncResult) – A [type`Gio`.AsyncResult] with the result of the operation

Raises:

GLib.Error

Returns:

a new TrackerSparqlConnection.

Return type:

Tracker.SparqlConnection

Finishes the operation started with [func`Tracker`.SparqlConnection.bus_new_async].

New in version 3.1.

classmethod new(flags, store, ontology, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

a new TrackerSparqlConnection.

Return type:

Tracker.SparqlConnection

Creates or opens a process-local database.

This method should only be used for databases owned by the current process. To connect to databases managed by other processes, use [ctor`Tracker`.SparqlConnection.bus_new].

If store is None, the database will be created in memory.

If defined, the ontology argument must point to a location containing suitable .ontology files in Turtle format. These define the structure of the triple store. You can learn more about ontologies, or you can use the stock Nepomuk ontologies by calling [func`Tracker`.sparql_get_ontology_nepomuk].

If opening an existing database, it is possible to pass None as the ontology location, the ontology will be introspected from the database. Passing a None ontology will raise an error if the database does not exist.

If a database is opened without the #TRACKER_SPARQL_CONNECTION_FLAG_READONLY flag enabled, and the given ontology holds differences with the current data layout, migration to the new structure will be attempted. This operation may raise an error. In particular, not all migrations are possible without causing data loss and Tracker will refuse to delete data during a migration. The database is always left in a consistent state, either prior or posterior to migration.

Operations on a [class`Tracker`.SparqlConnection] resulting on a [error`Tracker`.SparqlError.CORRUPT] error will have the event recorded persistently through a .meta.corrupted file alongside the database files. If the database is opened without the [flags`Tracker`.SparqlConnectionFlags.READONLY] flag and the file is found, this constructor will attempt to repair the database. In that situation, this constructor will either return a valid [class`Tracker`.SparqlConnection] if the database was repaired successfully, or raise a [error`Tracker`.SparqlError.CORRUPT] error if the database remains corrupted.

It is considered a developer error to ship ontologies that contain format errors, or that fail at migrations.

It is encouraged to use resource:/// URI locations for ontology wherever possible, so the triple store structure is tied to the executable binary, and in order to minimize disk seeks during TrackerSparqlConnection initialization.

classmethod new_async(flags, store, ontology, cancellable, callback, *user_data)
Parameters:
  • flags (Tracker.SparqlConnectionFlags) – Connection flags to define the SPARQL connection behavior

  • store (Gio.File or None) – The directory that contains the database as a [iface`Gio`.File], or None

  • ontology (Gio.File or None) – The directory that contains the database schemas as a [iface`Gio`.File], or None

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

  • callback (Gio.AsyncReadyCallback or None) – User-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.

  • user_data (object or None) – User-defined data to be passed to callback

Creates or opens a process-local database asynchronously.

See [ctor`Tracker`.SparqlConnection.new] for more information.

classmethod new_finish(result)
Parameters:

result (Gio.AsyncResult) – A [type`Gio`.AsyncResult] with the result of the operation

Raises:

GLib.Error

Return type:

Tracker.SparqlConnection

Finishes the operation started with [func`Tracker`.SparqlConnection.new_async].

classmethod remote_new(uri_base)
Parameters:

uri_base (str) – Base URI of the remote connection

Returns:

a new remote TrackerSparqlConnection.

Return type:

Tracker.SparqlConnection

Creates a connection to a remote HTTP SPARQL endpoint.

The connection is made using the libsoup HTTP library. The connection will normally use the https:// or http:// protocols.

close()

Closes a SPARQL connection.

No other API calls than GObject.Object.unref() should happen after this call.

This call is blocking. All pending updates will be flushed, and the store databases will be closed orderly. All ongoing SELECT queries will be cancelled. Notifiers will no longer emit events.

close_async(cancellable, callback, *user_data)
Parameters:
  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

  • callback (Gio.AsyncReadyCallback or None) – User-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.

  • user_data (object or None) – User-defined data to be passed to callback

Closes a SPARQL connection asynchronously.

No other API calls than GObject.Object.unref() should happen after this call.

close_finish(res)
Parameters:

res (Gio.AsyncResult) – A [type`Gio`.AsyncResult] with the result of the operation

Raises:

GLib.Error

Returns:

False if some error occurred, True otherwise

Return type:

bool

Finishes the operation started with [method`Tracker`.SparqlConnection.close_async].

create_batch()
Returns:

(nullable): A new [class`Tracker`.Batch]

Return type:

Tracker.Batch

Creates a new [class`Tracker`.Batch] to store and execute SPARQL updates.

If the connection is readonly or cannot issue SPARQL updates, None will be returned.

create_notifier()
Returns:

A newly created notifier.

Return type:

Tracker.Notifier or None

Creates a new [class`Tracker`.Notifier] to receive notifications about changes in self.

See [class`Tracker`.Notifier] documentation for information about how to use this object.

Connections to HTTP endpoints will return None.

deserialize_async(flags, format, default_graph, stream, cancellable, callback, *user_data)
Parameters:

Loads the RDF data contained in stream into the given self.

This is an asynchronous operation, callback will be invoked when the data has been fully inserted to self.

The RDF data will be inserted in the given default_graph if one is provided, or the anonymous graph if default_graph is None. Any RDF data that has a graph specified (e.g. using the GRAPH clause in the Trig format) will be inserted in the specified graph instead of default_graph.

The flags argument is reserved for future expansions, currently Tracker.DeserializeFlags.NONE must be passed.

New in version 3.4.

deserialize_finish(result)
Parameters:

result (Gio.AsyncResult) – A [type`Gio`.AsyncResult] with the result of the operation

Raises:

GLib.Error

Returns:

True if all data was inserted successfully.

Return type:

bool

Finishes the operation started with [method`Tracker`.SparqlConnection.deserialize_async].

New in version 3.4.

get_namespace_manager()
Returns:

a [class`Tracker`.NamespaceManager] with the prefixes of self.

Return type:

Tracker.NamespaceManager

Returns a [class`Tracker`.NamespaceManager] that contains all prefixes in the ontology of self.

load_statement_from_gresource(resource_path, cancellable)
Parameters:
  • resource_path (str) – The resource path of the file to parse.

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

Raises:

GLib.Error

Returns:

A prepared statement

Return type:

Tracker.SparqlStatement or None

Prepares a [class`Tracker`.SparqlStatement] for the SPARQL contained as a [struct`Gio`.Resource] file at resource_path.

SPARQL Query files typically have the .rq extension. This will use [method`Tracker`.SparqlConnection.query_statement] or [method`Tracker`.SparqlConnection.update_statement] underneath to indistinctly return SPARQL query or update statements.

New in version 3.3.

map_connection(handle_name, service_connection)
Parameters:
  • handle_name (str) – Handle name for service_connection

  • service_connection (Tracker.SparqlConnection) – a TrackerSparqlConnection to use from self

Maps a TrackerSparqlConnection onto another through a private:@handle_name URI.

This can be accessed via the SERVICE SPARQL syntax in queries from self. E.g.:

``c tracker_sparql_connection_map_connection (connection,

“other-connection”, other_connection);

``

``sparql SELECT ?u {

SERVICE <private:other-connection> {

?u a rdfs:Resource

}

}

This is useful to interrelate data from multiple TrackerSparqlConnection instances maintained by the same process, without creating a public endpoint for service_connection.

self may only be a TrackerSparqlConnection created via [ctor`Tracker`.SparqlConnection.new] and [func`Tracker`.SparqlConnection.new_async].

New in version 3.3.

query(sparql, cancellable)
Parameters:
  • sparql (str) – String containing the SPARQL query

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

Raises:

GLib.Error

Returns:

a [class`Tracker`.SparqlCursor] with the results.

Return type:

Tracker.SparqlCursor

Executes a SPARQL query on self.

This method is synchronous and will block until the query is executed. See [method`Tracker`.SparqlConnection.query_async] for an asynchronous variant.

If the query is partially built from user input or other untrusted sources, special care is required about possible SPARQL injection. In order to avoid it entirely, it is recommended to use [class`Tracker`.SparqlStatement]. The function [func`Tracker`.sparql_escape_string] exists as a last resort, but its use is not recommended.

query_async(sparql, cancellable, callback, *user_data)
Parameters:
  • sparql (str) – String containing the SPARQL query

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

  • callback (Gio.AsyncReadyCallback or None) – User-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.

  • user_data (object or None) – User-defined data to be passed to callback

Executes asynchronously a SPARQL query on self

If the query is partially built from user input or other untrusted sources, special care is required about possible SPARQL injection. In order to avoid it entirely, it is recommended to use [class`Tracker`.SparqlStatement]. The function [func`Tracker`.sparql_escape_string] exists as a last resort, but its use is not recommended.

query_finish(res)
Parameters:

res (Gio.AsyncResult) – A [type`Gio`.AsyncResult] with the result of the operation

Raises:

GLib.Error

Returns:

a [class`Tracker`.SparqlCursor] with the results.

Return type:

Tracker.SparqlCursor

Finishes the operation started with [method`Tracker`.SparqlConnection.query_async].

query_statement(sparql, cancellable)
Parameters:
  • sparql (str) – The SPARQL query

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

Raises:

GLib.Error

Returns:

A prepared statement

Return type:

Tracker.SparqlStatement or None

Prepares the given SELECT/ASK/DESCRIBE/CONSTRUCT SPARQL query as a [class`Tracker`.SparqlStatement].

This prepared statement can be executed through [method`Tracker`.SparqlStatement.execute] or [method`Tracker`.SparqlStatement.serialize_async] families of functions.

serialize_async(flags, format, query, cancellable, callback, *user_data)
Parameters:

Serializes a DESCRIBE or CONSTRUCT query into the specified RDF format.

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:

GLib.Error

Returns:

A [class`Gio`.InputStream] to read RDF content.

Return type:

Gio.InputStream

Finishes the operation started with [method`Tracker`.SparqlConnection.serialize_async].

New in version 3.3.

update(sparql, cancellable)
Parameters:
  • sparql (str) – String containing the SPARQL update query

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

Raises:

GLib.Error

Executes a SPARQL update on self.

This method is synchronous and will block until the update is finished. See [method`Tracker`.SparqlConnection.update_async] for an asynchronous variant.

It is recommented to consider the usage of [class`Tracker`.Batch] to cluster database updates. Frequent isolated SPARQL updates through this method will have a degraded performance in comparison.

If the query is partially built from user input or other untrusted sources, special care is required about possible SPARQL injection. In order to avoid it entirely, it is recommended to use [class`Tracker`.SparqlStatement], or to build the SPARQL input through [class`Tracker`.Resource]. The function [func`Tracker`.sparql_escape_string] exists as a last resort, but its use is not recommended.

update_array_async(sparql, sparql_length, cancellable, callback, *user_data)
Parameters:
  • sparql (str) – An array of strings containing the SPARQL update queries

  • sparql_length (int) – The amount of strings you pass as sparql

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

  • callback (Gio.AsyncReadyCallback or None) – User-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.

  • user_data (object or None) – User-defined data to be passed to callback

Executes asynchronously an array of SPARQL updates. All updates in the array are handled within a single transaction.

If the query is partially built from user input or other untrusted sources, special care is required about possible SPARQL injection. In order to avoid it entirely, it is recommended to use [class`Tracker`.SparqlStatement], or to build the SPARQL input through [class`Tracker`.Resource]. The function [func`Tracker`.sparql_escape_string] exists as a last resort, but its use is not recommended.

update_array_finish(res)
Parameters:

res (Gio.AsyncResult) – A [type`Gio`.AsyncResult] with the result of the operation

Raises:

GLib.Error

Returns:

True if there were no errors.

Return type:

bool

Finishes the operation started with [method`Tracker`.SparqlConnection.update_array_async].

update_async(sparql, cancellable, callback, *user_data)
Parameters:
  • sparql (str) – String containing the SPARQL update query

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

  • callback (Gio.AsyncReadyCallback or None) – User-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.

  • user_data (object or None) – User-defined data to be passed to callback

Executes asynchronously a SPARQL update.

It is recommented to consider the usage of [class`Tracker`.Batch] to cluster database updates. Frequent isolated SPARQL updates through this method will have a degraded performance in comparison.

If the query is partially built from user input or other untrusted sources, special care is required about possible SPARQL injection. In order to avoid it entirely, it is recommended to use [class`Tracker`.SparqlStatement], or to build the SPARQL input through [class`Tracker`.Resource]. The function [func`Tracker`.sparql_escape_string] exists as a last resort, but its use is not recommended.

update_blank(sparql, cancellable)
Parameters:
  • sparql (str) – String containing the SPARQL update query

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

Raises:

GLib.Error

Returns:

a [type`GLib`.Variant] with the generated URNs.

Return type:

GLib.Variant

Executes a SPARQL update and returns the names of the generated blank nodes.

This method is synchronous and will block until the update is finished. See [method`Tracker`.SparqlConnection.update_blank_async] for an asynchronous variant.

The sparql query should be built with [class`Tracker`.Resource], or its parts correctly escaped using [func`Tracker`.sparql_escape_string], otherwise SPARQL injection is possible.

The format string of the GVariant is aaa{ss} (an array of an array of dictionaries). The first array represents each INSERT that may exist in the SPARQL string. The second array represents each new node for a given WHERE clause. The last array holds a string pair with the blank node name (e.g. foo for the blank node _:foo) and the URN that was generated for it. For most updates the first two outer arrays will only contain one item.

Deprecated since version 3.5: This function makes the expectation that blank nodes have a durable name that persist. The SPARQL and RDF specs define a much more reduced scope for blank node labels. This function advises a behavior that goes against that reduced scope, and will directly make the returned values meaningless if the Tracker.SparqlConnectionFlags.ANONYMOUS_BNODES flag is defined in the connection. Users that want names generated for them, should look for other methods (e.g. IRIs containing UUIDv4 strings).

update_blank_async(sparql, cancellable, callback, *user_data)
Parameters:
  • sparql (str) – String containing the SPARQL update query

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

  • callback (Gio.AsyncReadyCallback or None) – User-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.

  • user_data (object or None) – User-defined data to be passed to callback

Executes asynchronously a SPARQL update and returns the names of the generated blank nodes.

See the [method`Tracker`.SparqlConnection.update_blank] documentation to learn the differences with [method`Tracker`.SparqlConnection.update].

Deprecated since version 3.5: See [method`Tracker`.SparqlConnection.update_blank].

update_blank_finish(res)
Parameters:

res (Gio.AsyncResult) – A [type`Gio`.AsyncResult] with the result of the operation

Raises:

GLib.Error

Returns:

a [type`GLib`.Variant] with the generated URNs.

Return type:

GLib.Variant

Finishes the operation started with [method`Tracker`.SparqlConnection.update_blank_async].

This method returns the URNs of the generated nodes, if any. See the [method`Tracker`.SparqlConnection.update_blank] documentation for the interpretation of the returned [type`GLib`.Variant].

Deprecated since version 3.5: See [method`Tracker`.SparqlConnection.update_blank].

update_finish(res)
Parameters:

res (Gio.AsyncResult) – A [type`Gio`.AsyncResult] with the result of the operation

Raises:

GLib.Error

Finishes the operation started with [method`Tracker`.SparqlConnection.update_async].

update_resource(graph, resource, cancellable)
Parameters:
  • graph (str or None) – RDF graph where the resource should be inserted/updated, or None for the default graph

  • resource (Tracker.Resource) – A [class`Tracker`.Resource]

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

Raises:

GLib.Error

Returns:

True if there were no errors.

Return type:

bool

Inserts a resource as described by resource on the given graph.

This method is synchronous and will block until the update is finished. See [method`Tracker`.SparqlConnection.update_resource_async] for an asynchronous variant.

It is recommented to consider the usage of [class`Tracker`.Batch] to cluster database updates. Frequent isolated SPARQL updates through this method will have a degraded performance in comparison.

New in version 3.1.

update_resource_async(graph, resource, cancellable, callback, *user_data)
Parameters:
  • graph (str or None) – RDF graph where the resource should be inserted/updated, or None for the default graph

  • resource (Tracker.Resource) – A [class`Tracker`.Resource]

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

  • callback (Gio.AsyncReadyCallback or None) – User-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.

  • user_data (object or None) – User-defined data to be passed to callback

Inserts asynchronously a resource as described by resource on the given graph.

It is recommented to consider the usage of [class`Tracker`.Batch] to cluster database updates. Frequent isolated SPARQL updates through this method will have a degraded performance in comparison.

New in version 3.1.

update_resource_finish(res)
Parameters:

res (Gio.AsyncResult) – A [type`Gio`.AsyncResult] with the result of the operation

Raises:

GLib.Error

Returns:

True if there were no errors.

Return type:

bool

Finishes the operation started with [method`Tracker`.SparqlConnection.update_resource_async].

New in version 3.1.

update_statement(sparql, cancellable)
Parameters:
  • sparql (str) – The SPARQL update

  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

Raises:

GLib.Error

Returns:

A prepared statement

Return type:

Tracker.SparqlStatement or None

Prepares the given INSERT/DELETE SPARQL as a [class`Tracker`.SparqlStatement].

This prepared statement can be executed through the [method`Tracker`.SparqlStatement.update] family of functions.

New in version 3.5.