### Class

# Tracker SparqlConnection

#### Description [src]

    abstract class Tracker.SparqlConnection : GObject.Object
    {
      /* No available fields */
    }

`TrackerSparqlConnection` holds a connection to a RDF triple store.

This triple store may be of three types:

- Local to the process, created through `tracker_sparql_connection_new()`.
- A HTTP SPARQL endpoint over the network, created through `tracker_sparql_connection_remote_new()`
- A DBus SPARQL endpoint owned by another process in the same machine, created through `tracker_sparql_connection_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 `TrackerEndpoint`, see `tracker_endpoint_dbus_new()` and `tracker_endpoint_http_new()`.

When issuing SPARQL queries and updates, it is recommended that these are created through `TrackerSparqlStatement` to avoid the SPARQL injection class of bugs, see `tracker_sparql_connection_query_statement()` and `tracker_sparql_connection_update_statement()`. For SPARQL updates it is also possible to use a “builder” approach to generate RDF data, see `TrackerResource`. It is also possible to create `TrackerSparqlStatement` objects for SPARQL queries and updates from SPARQL strings embedded in a `GResource`, see `tracker_sparql_connection_load_statement_from_gresource()`.

To get the best performance, it is recommended that SPARQL updates are clustered through `TrackerBatch`.

`TrackerSparqlConnection` also offers a number of methods for the simple cases, `tracker_sparql_connection_query()` may be used when there is a SPARQL query string directly available, and the `tracker_sparql_connection_update()` family of functions may be used for one-off updates. All functions have asynchronous variants.

When a SPARQL query is executed, a `TrackerSparqlCursor` 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 `TrackerNotifier` obtained with `tracker_sparql_connection_create_notifier()`.

After done with a connection, it is recommended to call `tracker_sparql_connection_close()` or `tracker_sparql_connection_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 `tracker_sparql_escape_string()` for literal strings and the `tracker_sparql_escape_uri()` family of functions for URIs.

#### Ancestors

- GObject

#### Constructors

###### tracker_sparql_connection_bus_new

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

###### tracker_sparql_connection_bus_new_finish

Finishes the operation started with `tracker_sparql_connection_bus_new_async()`.

since: 3.1

###### tracker_sparql_connection_new

Creates or opens a process-local database.

###### tracker_sparql_connection_new_finish

Finishes the operation started with `tracker_sparql_connection_new_async()`.

###### tracker_sparql_connection_remote_new

Creates a connection to a remote HTTP SPARQL endpoint.

#### Functions

###### tracker_sparql_connection_bus_new_async

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

since: 3.1

###### tracker_sparql_connection_new_async

Creates or opens a process-local database asynchronously.

#### Instance methods

###### tracker_sparql_connection_close

Closes a SPARQL connection.

###### tracker_sparql_connection_close_async

Closes a SPARQL connection asynchronously.

###### tracker_sparql_connection_close_finish

Finishes the operation started with `tracker_sparql_connection_close_async()`.

###### tracker_sparql_connection_create_batch

Creates a new `TrackerBatch` to store and execute SPARQL updates.

###### tracker_sparql_connection_create_notifier

Creates a new `TrackerNotifier` to receive notifications about changes in `connection`.

###### tracker_sparql_connection_deserialize_async

Loads the RDF data contained in `stream` into the given `connection`.

since: 3.4

###### tracker_sparql_connection_deserialize_finish

Finishes the operation started with `tracker_sparql_connection_deserialize_async()`.

since: 3.4

###### tracker_sparql_connection_get_namespace_manager

Returns a `TrackerNamespaceManager` that contains all prefixes in the ontology of `connection`.

###### tracker_sparql_connection_load_statement_from_gresource

Prepares a `TrackerSparqlStatement` for the SPARQL contained as a `GResource` file at `resource_path`.

since: 3.3

###### tracker_sparql_connection_map_connection

Maps a `TrackerSparqlConnection` onto another through a `private:`handle_name“ URI.

since: 3.3

###### tracker_sparql_connection_query

Executes a SPARQL query on `connection`.

###### tracker_sparql_connection_query_async

Executes asynchronously a SPARQL query on `connection`.

###### tracker_sparql_connection_query_finish

Finishes the operation started with `tracker_sparql_connection_query_async()`.

###### tracker_sparql_connection_query_statement

Prepares the given `SELECT`/`ASK`/`DESCRIBE`/`CONSTRUCT` SPARQL query as a `TrackerSparqlStatement`.

###### tracker_sparql_connection_serialize_async

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

since: 3.3

###### tracker_sparql_connection_serialize_finish

Finishes the operation started with `tracker_sparql_connection_serialize_async()`.

since: 3.3

###### tracker_sparql_connection_update

Executes a SPARQL update on `connection`.

###### tracker_sparql_connection_update_array_async

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

###### tracker_sparql_connection_update_array_finish

Finishes the operation started with `tracker_sparql_connection_update_array_async()`.

###### tracker_sparql_connection_update_async

Executes asynchronously a SPARQL update.

###### tracker_sparql_connection_update_blank

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

deprecated: 3.5

###### tracker_sparql_connection_update_blank_async

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

deprecated: 3.5

###### tracker_sparql_connection_update_blank_finish

Finishes the operation started with `tracker_sparql_connection_update_blank_async()`.

deprecated: 3.5

###### tracker_sparql_connection_update_finish

Finishes the operation started with `tracker_sparql_connection_update_async()`.

###### tracker_sparql_connection_update_resource

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

since: 3.1

###### tracker_sparql_connection_update_resource_async

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

since: 3.1

###### tracker_sparql_connection_update_resource_finish

Finishes the operation started with `tracker_sparql_connection_update_resource_async()`.

since: 3.1

###### tracker_sparql_connection_update_statement

Prepares the given `INSERT`/`DELETE` SPARQL as a `TrackerSparqlStatement`.

since: 3.5

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct TrackerSparqlConnectionClass {
      /* no available fields */
    }

No description available.