# Overview

The libtracker-sparql library is the foundation for Tracker querying and inserting into the data store. The data store allows both querying and inserting using SPARQL based on the Nepomuk ontology.

## Connection methods

The Tracker SPARQL library provides several underlying methods to perform queries and updates to the Tracker Store.

- Direct Access:

  All Read-Only operations done in a TrackerSparqlConnection will by default use this method, as it doesn't involve any D-Bus traffic, and thus, it will perform much better. There is no real connection with the Tracker Store in this case, as the access is direct to the underlying SQLite database. Again, note that this method applies only to Read-Only operations.

  If you plan to only do Read-Only queries to the store, you can get the TrackerSparqlConnection object using `tracker_sparql_connection_get_direct`. Otherwise, if you also plan to use the same connection object for updates, you must get the connection object with `tracker_sparql_connection_get`.

- D-Bus FD passing:

  If the system runs a D-Bus ≥ 1.3.1, the TrackerSparqlConnection will use the File Descriptor passing method via D-Bus to connect to the Store, which is faster than the plain D-Bus for queries involving a lot of traffic. This method will be used for all non read-only queries on TrackerSparqlConnection objects obtained with `tracker_sparql_connection_get`.

- D-Bus:

  If the system runs a D-Bus < 1.3.1, the TrackerSparqlConnection will use the standard D-Bus method to connect to the Store. This method will be used for all non read-only queries on TrackerSparqlConnection objects obtained with `tracker_sparql_connection_get`.

Please note that the user of the library cannot choose a specific method to be used, as that is done automatically by the TrackerSparqlConnection depending on the available possibilities.

## Compiling applications

To compile applications using libtracker-sparql, you need to tell the compiler where to find the proper header files and libraries. This is done with the pkg-config utility.

The following interactive shell session demonstrates how pkg-config is used (the actual output on your system may be different):

    $ pkg-config --cflags tracker-sparql-0.9
     -pthread -I/usr/include/tracker-0.9 -I/usr/include/tracker-0.9/libtracker-sparql -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include

    $ pkg-config --libs tracker-sparql-0.9
     -Wl,--export-dynamic -pthread -ltracker-sparql-0.9 -lgio-2.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0

The simplest way to compile a program is to use the "backticks" feature of the shell. If you enclose a command in backticks (not single quotes), then its output will be substituted into the command line before execution:

     $ cc `pkg-config --cflags --libs tracker-sparql-0.9` hello.c -o hello