#### Commandline reference

TinySPARQL offers a number of commandline utilities to manipulate, create, and access SPARQL endpoints and TinySPARQL databases.

## tinysparql-endpoint

tinysparql-endpoint

## Name

tinysparql-endpoint — Create a SPARQL endpoint

## Synopsis

    tinysparql endpoint [--dbus-service | -b] <service_name>
                      [--database-path | -d] <database_path>
                      [[--ontology | -o] <ontology_name> |
                       [--ontology-path | -p] <ontology_path>]
                      [--http-port] <port>
                      [--loopback]
                      [[--system | --session]]

## DESCRIPTION

This command allows creating SPARQL endpoints. The endpoint will be able to handle SPARQL select and update queries, and notify about changes in it.

The endpoint is exported via DBus, accessible through the given service_name, either using it in a SERVICE clause, or by creating a dedicated bus-based SPARQL connection.

When creating a database, the ontology_name (or alternatively, a ontology_path) must be provided in order to generate the database. If ontology_name is used, the ontology must exist in $datadir/tracker/ontologies

Users should be careful about the —http-port option, consider using it only combined with the —loopback option.

The database itself will be stored according to database_path.

## OPTIONS

-b, —dbus-service=<service_name>
  Service name to use on the endpoint.
-d, —database-path=<database_path>
  The path where the database will be stored.
-o, —ontology
  The name of an ontology in $datadir/tracker/ontologies to use on the constructed database.
-p, —ontology-path
  Full path to an ontology to use on the constructed database.
—session
  Use the session bus. This is the default.
—system
  Use the system bus.
-l, —list
  List all SPARQL endpoints available in DBus
-L, —list-http
  List network-local HTTP SPARQL endpoints
—http-port
  Creates a HTTP endpoint that listens in the specified port
—loopback
  Allows only HTTP connections in the loopback device. Only effective with HTTP endpoints.

## EXAMPLES

Export a Nepomuk endpoint with the org.example.Example1 bus name.

    $ tinysparql endpoint -b org.example.Example1 -o nepomuk -d /tmp/example1

Access this endpoint with the tinysparql-sparql(1) subcommand.

    $ tinysparql sparql --dbus-service org.example.Example1 -q "
      SELECT ?s ?o
      WHERE {
        ?u a ?o
      }"

Export a Nepomuk endpoint via HTTP.

    $ tinysparql endpoint --http-port 8080 -o nepomuk --loopback

Access this endpoint via HTTP.

    $ tinysparql sparql --remote-service http://127.0.0.1:8080/sparql -q "
      SELECT ?u {
        ?u a rdfs:Resource
      }"

## SEE ALSO

tinysparql-sparql(1),

https://www.w3.org/TR/sparql11-query/

## tinysparql-export

tinysparql-export

## Name

tinysparql-export — Export all data from a TinySPARQL database.

## Synopsis

tinysparql export [options…] [IRI…]

## DESCRIPTION

tinysparql export exports data stored in a TinySPARQL database, in Turtle format. By default all data is exported, if any IRI, only those resources will be printed.

The output is intended to be machine-readable, not human readable. Use a tool such as rapper(1) to convert the data to different formats.

## OPTIONS

-o, —output-format=<RDF_FORMAT>
  Choose which RDF format to use to output results. Supported formats are turtle, trig and json-ld.
-g, —show-graphs
  Deprecated. Does the same than —output-format trig.
—2to3
  Helper for migrating data from Tracker 2.x databases. This option takes an argument specifying the scope. Only the “files-starred” argument is available so far.
—keyfile
  Outputs the data in a key file format. Only may be used with —2to3

## EXAMPLES

Export all data from Tracker Index and prettify the output using rapper(1).::

    $ tinysparql export -b org.freedesktop.Tracker3.Miner.Files | rapper - -I . -i turtle -o turtle

## SEE ALSO

tinysparql-import(1), tinysparql-sparql(1).

## tinysparql-import

tinysparql-import

## Name

tinysparql-import — Import data into a TinySPARQL database.

## Synopsis

tinysparql import FILE.ttl

## DESCRIPTION

tinysparql import imports data into a TinySPARQL database.

The data must conform to the existing ontology of the database.

The data must be in Turtle format. You can use a tool such as rapper(1) to convert the data from other formats to Turtle.

## SEE ALSO

tinysparql-export(1), tinysparql-sparql(1).

## tinysparql-introspect

tinysparql-introspect

## Name

tinysparql-introspect — Introspect SPARQL endpoints.

## Synopsis

    tinysparql introspect [(-d |--database) <file> | (-b | --dbus-service) <busname> | (-r | --remote-service) <url>]
        [(-t | --tree)] [(-t | --tree) <class>] [(-s | --search) <needle>]t
    tinysparql introspect [(-d |--database) <file> | (-b | --dbus-service) <busname> | (-r | --remote-service) <url>]
        [(-c | --list-classes)] [(-p | --list-properties)] [(-i | --list-indexes)] [(-n | --list-notifies)] [(-g | --list-graphs)]

## DESCRIPTION

This command allows probing of the current database schema (also known as ontology) and endpoint capabilities. If called with no additional arguments to the one specifying the database connection, all information is extracted.

In terms of the database ontology, it’s easy to find out what properties are indexed for speed, or notified on changes, what classes are available and the properties belonging to those classes. There are also visual tools to display an ascii tree layout of the classes and their relationships to each other.

## OPTIONS

-b, —dbus-service=<service_name>
  Connects to a SPARQL endpoint at a D-Bus name.
-d, —database-path=<database_path>
  Connects to a database by location in the filesystem.
-r, —remote-service=<url>
  Connects to a HTTP SPARQL endpoint.
-c, —list-classes
  Returns a list of classes which describe the ontology used for storing data. These classes are also used in queries. For example, http://www.w3.org/2000/01/rdf-schema#Resource is one of many classes which should be returned here.
-x, —list-class-prefixes
  Returns a list of prefixes in shortened and long form. All RDF classes and properties have such a prefix that may be expressed in either form.
-p, —list-properties=[class]
  Returns a list of properties which pertain to a class. You can use both formats here for the class, either the full name http://tracker.api.gnome.org/ontology/v3/nfo#Video or the shortened prefix name nfo:Video. See also —tree and —query.
-n, —list-notifies=[class]
  Returns a list of classes which are notified over D-Bus about any changes that occur in the database. The class does not have to be supplied here. This is optional and filters the results according to any argument supplied. With no class, all classes are listed.
-i, —list-indexes=[property]
  Returns a list of properties which are indexed in the database. Indexes improves query speed but also add an indexing penalty. The property does not have to be supplied here. This is optional and filters the results according to any argument supplied. With no property, all properties are listed.
-g, —list-graphs
  List all the named graphs in the database. These are used by the filesystem miner to separate metadata so that apps can only see the information relevant to them.
-t, —tree=[class]
  Prints a tree showing all parent classes of class in the ontology. The class can be provided in shorthand or longhand (see —get-shorthand and —get-longhand for details).

If no class is given, the entire tree is shown.

The —search command line option can be used to highlight parts of the tree you’re looking for. The search is case insensitive.

The —properties command line option can be used to show properties for each class displayed

-s, —search=<needle>
  Returns a list of classes and properties which partially match needle in the ontology. Search is case insensitive. See also —tree.

## SEE ALSO

tinysparql-endpoint(1).

## tinysparql-query

tinysparql-query

## Name

tinysparql-query — Query to SPARQL endpoints.

## Synopsis

    tinysparql query [(-d |--database) <file> | (-b | --dbus-service) <busname> | (-r | --remote-service) <url>]
        (-f | --file) <file>] [(-u | --update)] [-a <parameter>:<value>]... [SPARQL]

## DESCRIPTION

This command allows running queries or updates on a SPARQL endpoint.

When the caller runs a query, the query is in the SPARQL language. This can be done two ways. Either by providing a file with the query or by providing a string with the sparql query.

The file argument can be either a local path or a URI. It also does not have to be an absolute path.

## OPTIONS

-b, —dbus-service=<service_name>
  Connects to a SPARQL endpoint at a D-Bus name.
-d, —database-path=<database_path>
  Connects to a database by location in the filesystem.
-r, —remote-service=<url>
  Connects to a HTTP SPARQL endpoint.
-f, —file=<file>
  Use a file with SPARQL content to query or update.
-u, —update
  This has to be used with —query. This tells “tinysparql query” to use the SPARQL update extensions so it knows it isn’t a regular data lookup request. So if your query is intended to change data in the database, this option is needed.
-a, —arg=<parameter>:<value>

  Provides an argument for a parameter declared in the SPARQL query string. This may be used with —file, —query or —update. Multiple arguments may be provided for multiple parameters. Argument values are provided as a colon separated string containing 3 values: name, type and value. The name is the same as used in the query string, the value is the desired value, and the type is a single-character string defining the type:

  - i: The value will describe an integer
  - d: The value will describe a floating point number
  - b: The value will describe a boolean
  - s: The value will describe a plain string

## EXAMPLES

Querying a D-Bus endpoint

      $ tinysparql query --dbus-service org.example.Endpoint "SELECT ('Hello World' AS ?str) {}"

Updating a database directly from a query in a file

      $ tinysparql query --database /tmp/db/ --update --file ./update.rq

Using —arg to provide a arguments to query parameters

      $ tinysparql query -b org.example.Endpoint \
          -a name:s:"John" -a age:i:42 -a available:b:true \
          "SELECT (~name AS ?name) (~age AS ?age) (~available AS ?avail) { }"

## SEE ALSO

tinysparql-endpoint(1).

https://gnome.pages.gitlab.gnome.org/tinysparql/tutorial.html.

## tinysparql-sql

tinysparql-sql

## Name

tinysparql-sql — Use SQL to query the TinySPARQL databases.

## Synopsis

    tinysparql sql -q <sql> | -f <file>

## DESCRIPTION

This command allows probing of the current database. When using commands like tinysparql sparql, the SPARQL used is translated into SQL before being run on the database. This allows direct use of the database using SQL avoiding the SPARQL engine entirely.

The caller can run a query two ways, either by providing a file with the query or by providing a string with the sql query.

The file argument can be either a local path or a URI. It also does not have to be an absolute path.

## OPTIONS

-f, —file=<file>
  Use a file with SPARQL content to query. Don’t forget to end all queries with a semicolon (;) and also to use quotes around table names. The quotes are important because most tables are named after ontology classes like “nfo:Document” and queries will fail without the quotes.
-q, —query=<sql>
  Use a sql string to query the database with.

## EXAMPLES

Show first 10 “nfo:Document” entries where the TOC is not NULL

      $ tinysparql sql -q 'SELECT * FROM "nfo:Document" WHERE "nfo:tableOfContents" NOT NULL LIMIT 10;'

## SEE ALSO

tinysparql-sparql(1), tinysparql-info(1).

http://en.wikipedia.org/wiki/SQL