Querying local files from the command line
On this page
Using Comunica SPARQL File, you can query over RDF files that are stored on your local machine.
1. Installation
Since Comunica runs on Node.js, make sure you have Node.js installed on your machine.
Next, we can install Comunica SPARQL on our machine:
$ npm install -g @comunica/query-sparql-file
2. SPARQL querying over one local file
After installing Comunica SPARQL, you will be given access to several commands including comunica-sparql-file
,
which allows you to execute SPARQL queries from the command line.
Just like comunica-sparql
, this command requires one or more URLs to be provided as sources to query over.
As last argument, as SPARQL query string can be provided.
For example, the following query retrieves the first 100 triples from path/to/my/file.ttl
:
$ comunica-sparql-file path/to/my/file.ttl \ "SELECT * WHERE { ?s ?p ?o } LIMIT 100"
3. SPARQL querying over one remote file
Next to local file, also remote files identified by a URL can be queried:
$ comunica-sparql-file https://www.rubensworks.net/ \ "SELECT * WHERE { ?s ?p ?o } LIMIT 100"
4. Learn more
This guide only discussed the basic functionality of comunica-sparql-file
.
You can learn more options by invoking the help command, or by reading the Comunica SPARQL documentation:
$ comunica-sparql-file --help