SPARQL — linkml documentation

# SPARQL

## Overview

This generator allows you to generate a bank of sparql queries from a schema

To run:

    gen-sparql -d sparql personinfo.yaml

See also

Data Validation for other validation strategies

See also

linkml-sparql for alpha version of a SPARQL based ORM

## Docs

### Command Line

#### gen-sparql

Generate SPARQL queries for validation

    gen-sparql [OPTIONS] YAMLFILE

Options

-d, --dir <dir>

  Output directory

-f, --format <format>

  Output format (default=sparql)

  Options

    sparql

--metadata, --no-metadata

  Include metadata in output (default=–metadata)

--useuris, --metauris

  Include metadata in output (default=–useuris)

-im, --importmap <importmap>

  Import mapping file

--log_level <log_level>

  Logging level (default=WARNING)

  Options

    CRITICAL | ERROR | WARNING | INFO | DEBUG

--mergeimports, --no-mergeimports

  Merge imports into source file (default=mergeimports)

Arguments

YAMLFILE

  Required argument

### Code

class linkml.generators.sparqlgen.SparqlGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], format: str = 'sparql', named_graphs: Optional[List[str]] = None, limit: Optional[int] = None, **kwargs)
  serialize(directory=None) → str

    Generate output in the required format

    Parameters

      kwargs – Generater specific parameters

    Returns

      Generated output