SPARQL commands¶
Validate syntax¶
kurra sparql validate 'SELECT * WHERE { ?s ?p ?o }'
kurra sparql validate 'INSERT DATA { <urn:s> <urn:p> <urn:o> }'
kurra sparql validate query.sparql
The required positional argument q accepts SPARQL text or a path to a file containing a query or update, just like
q in kurra sparql <path-or-url> <q>. Quote inline SPARQL text so the shell passes it as one argument.
Successful validation prints Valid SPARQL syntax and exits with status 0. Invalid syntax produces an error with
the line and column and exits with a nonzero status. The command checks syntax without executing the statement or
contacting an endpoint.
Run queries and updates¶
The existing invocation remains supported:
An explicit query subcommand is also available:
Use kurra sparql --help, kurra sparql query --help, or kurra sparql validate --help for command help.
Command reference¶
kurra.cli.commands.sparql ¶
CLI commands for running SPARQL queries.
SparqlGroup ¶
Bases: TyperGroup
Keep the original positional query invocation alongside subcommands.
validate_command ¶
Validate Q, a SPARQL query/update string or a path to a file containing one.
Source code in kurra/cli/commands/sparql.py
sparql_command ¶
sparql_command(path_or_url: Path, q: str, response_format: str = typer.Option('table', '--response-format', '-f', help="The response format of the SPARQL query. Either 'table' (default), 'json' or 'csv'"), username: str | None = None, password: str | None = None, timeout: int = 60) -> None
Run a SPARQL query against a local RDF file or a SPARQL endpoint, and print the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_or_url
|
Path
|
A local RDF file path or a SPARQL endpoint URL to query. |
required |
q
|
str
|
A SPARQL query string, or the path to a file containing one. |
required |
response_format
|
str
|
The response format of the SPARQL query. Either |
Option('table', '--response-format', '-f', help="The response format of the SPARQL query. Either 'table' (default), 'json' or 'csv'")
|
username
|
str | None
|
Fuseki username, if the endpoint requires authentication. |
None
|
password
|
str | None
|
Fuseki password, if the endpoint requires authentication. |
None
|
timeout
|
int
|
Timeout per request, in seconds. |
60
|
Raises:
| Type | Description |
|---|---|
BadParameter
|
If |