modules/rdf/sparql.zzm

rdf-0.0.3 documentation

NAME

rdf/sparql - SPARQL query execution.

SYNOPSIS

  from rdf/sparql import sparql_query, sparql_update;

  let rows := sparql_query(store, """
  SELECT ?s WHERE { ?s ?p ?o }
  """);

  sparql_update(store, """
  INSERT DATA { <s> <p> "o" . }
  """);

DESCRIPTION

This module parses, validates, executes, prepares, and diagnoses SPARQL 1.1 Query and Update strings over RDFStore. Query results are returned as dictionaries: select results include variables and results, ask results include boolean, and graph results include quads. Update execution returns a dictionary describing the update operations performed.

EXPORTS

Classes

  • SPARQLPreparedQuery

    Construct with source. The query is parsed during construction and available from get_ast.

    • execute(RDFStore store, inherited_dataset := null)

      Executes the prepared query against store.

  • SPARQLPreparedUpdate

    Construct with source. The update is parsed during construction and available from get_ast.

    • execute(RDFStore store)

      Executes the prepared update against store.

Functions

  • sparql_parse(String query)

    Parses SPARQL Query or Update syntax and returns an AST dictionary.

  • sparql_parse_query(String query)

    Alias for parsing query syntax retained for callers that want a query entry point.

  • sparql_prepare_query(String query)

    Returns a SPARQLPreparedQuery, throwing SPARQLError if the source is an update or invalid syntax.

  • sparql_prepare_update(String update)

    Returns a SPARQLPreparedUpdate, throwing SPARQLError if the source is not an update or has invalid syntax.

  • sparql_validate(String source)

    Returns a validation dictionary with ok, type, syntax, and error.

  • sparql_diagnose(RDFStore store, String source)

    Validates then executes source, returning validation information plus a result on success or error on failure.

  • sparql_query(RDFStore store, String query, inherited_dataset := null)

    Executes a SPARQL Query string over store. Throws if given Update syntax.

  • sparql_update(RDFStore store, String update)

    Executes a SPARQL Update string over store. Throws if given Query syntax.

COPYRIGHT AND LICENCE

rdf/sparql is copyright Toby Inkster.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.