# rdflib.plugins.sparql.results package

## Submodules

## rdflib.plugins.sparql.results.csvresults module

This module implements a parser and serializer for the CSV SPARQL result formats

http://www.w3.org/TR/sparql11-results-csv-tsv/

class rdflib.plugins.sparql.results.csvresults.CSVResultParser

  Bases: `ResultParser`

  __annotations__ = {}
  __init__()
  __module__ = 'rdflib.plugins.sparql.results.csvresults'
  convertTerm(t)
    Parameters:

      t (`str`)

    Return type:

      `Union`[`BNode`, `URIRef`, `Literal`, `None`]

  parse(source, content_type=None)

    return a Result object

    Parameters:

      - source (`IO`)

      - content_type (`Optional`[`str`])

    Return type:

      `Result`

  parseRow(row, v)
    Parameters:

      - row (`List`[`str`])

      - v (`List`[`Variable`])

    Return type:

      `Dict`[`Variable`, `Union`[`BNode`, `URIRef`, `Literal`]]

class rdflib.plugins.sparql.results.csvresults.CSVResultSerializer(result)

  Bases: `ResultSerializer`

  Parameters:

    result (`SPARQLResult`)

  __annotations__ = {}
  __init__(result)
    Parameters:

      result (`SPARQLResult`)

  __module__ = 'rdflib.plugins.sparql.results.csvresults'
  serialize(stream, encoding='utf-8', **kwargs)

    return a string properly serialized

    Parameters:

      - stream (`IO`)

      - encoding (`str`)

    Return type:

      `None`

  serializeTerm(term, encoding)
    Parameters:

      - term (`Optional`[`Identifier`])

      - encoding (`str`)

    Return type:

      `Union`[`str`, `Identifier`]

## rdflib.plugins.sparql.results.graph module

class rdflib.plugins.sparql.results.graph.GraphResultParser

  Bases: `ResultParser`

  __annotations__ = {}
  __module__ = 'rdflib.plugins.sparql.results.graph'
  parse(source, content_type)

    return a Result object

    Parameters:

      - source (`IO`)

      - content_type (`Optional`[`str`])

    Return type:

      `Result`

## rdflib.plugins.sparql.results.jsonresults module

A Serializer for SPARQL results in JSON:

http://www.w3.org/TR/rdf-sparql-json-res/

Bits and pieces borrowed from: http://projects.bigasterisk.com/sparqlhttp/

Authors: Drew Perttula, Gunnar Aastrand Grimnes

class rdflib.plugins.sparql.results.jsonresults.JSONResult(json)

  Bases: `Result`

  Parameters:

    json (`Dict`[`str`, `Any`])

  __annotations__ = {}
  __init__(json)
    Parameters:

      json (`Dict`[`str`, `Any`])

  __module__ = 'rdflib.plugins.sparql.results.jsonresults'

class rdflib.plugins.sparql.results.jsonresults.JSONResultParser

  Bases: `ResultParser`

  __annotations__ = {}
  __module__ = 'rdflib.plugins.sparql.results.jsonresults'
  parse(source, content_type=None)

    return a Result object

    Parameters:

      - source (`IO`)

      - content_type (`Optional`[`str`])

    Return type:

      `Result`

class rdflib.plugins.sparql.results.jsonresults.JSONResultSerializer(result)

  Bases: `ResultSerializer`

  Parameters:

    result (`Result`)

  __annotations__ = {}
  __init__(result)
    Parameters:

      result (`Result`)

  __module__ = 'rdflib.plugins.sparql.results.jsonresults'
  serialize(stream, encoding=None)

    return a string properly serialized

    Parameters:

      - stream (`IO`)

      - encoding (`str`)

    Return type:

      `None`

rdflib.plugins.sparql.results.jsonresults.parseJsonTerm(d)

  rdflib object (Literal, URIRef, BNode) for the given json-format dict.

  input is like:

    { ‘type’: ‘uri’, ‘value’: ‘http://famegame.com/2006/01/username’ } { ‘type’: ‘literal’, ‘value’: ‘drewp’ }

  Parameters:

    d (`Dict`[`str`, `str`])

  Return type:

    `Identifier`

rdflib.plugins.sparql.results.jsonresults.termToJSON(self, term)
  Parameters:

    - self (`JSONResultSerializer`)

    - term (`Optional`[`Identifier`])

  Return type:

    `Optional`[`Dict`[`str`, `str`]]

## rdflib.plugins.sparql.results.rdfresults module

class rdflib.plugins.sparql.results.rdfresults.RDFResult(source, **kwargs)

  Bases: `Result`

  Parameters:

    - source (`Union`[`IO`, `Graph`])

    - kwargs (`Any`)

  __annotations__ = {}
  __init__(source, **kwargs)
    Parameters:

      - source (`Union`[`IO`, `Graph`])

      - kwargs (`Any`)

  __module__ = 'rdflib.plugins.sparql.results.rdfresults'

class rdflib.plugins.sparql.results.rdfresults.RDFResultParser

  Bases: `ResultParser`

  __annotations__ = {}
  __module__ = 'rdflib.plugins.sparql.results.rdfresults'
  parse(source, **kwargs)

    return a Result object

    Parameters:

      - source (`Union`[`IO`, `Graph`])

      - kwargs (`Any`)

    Return type:

      `Result`

## rdflib.plugins.sparql.results.tsvresults module

This implements the Tab Separated SPARQL Result Format

It is implemented with pyparsing, reusing the elements from the SPARQL Parser

class rdflib.plugins.sparql.results.tsvresults.TSVResultParser

  Bases: `ResultParser`

  __annotations__ = {}
  __module__ = 'rdflib.plugins.sparql.results.tsvresults'
  convertTerm(t)
    Parameters:

      t (`Union`[`object`, `Literal`, `BNode`, `CompValue`, `URIRef`])

    Return type:

      `Union`[`object`, `BNode`, `URIRef`, `Literal`, `None`]

  parse(source, content_type=None)

    return a Result object

    Parameters:

      - source (`IO`)

      - content_type (`Optional`[`str`])

    Return type:

      `Result`

## rdflib.plugins.sparql.results.txtresults module

class rdflib.plugins.sparql.results.txtresults.TXTResultSerializer(result)

  Bases: `ResultSerializer`

  A write-only QueryResult serializer for text/ascii tables

  Parameters:

    result (`Result`)

  __annotations__ = {}
  __module__ = 'rdflib.plugins.sparql.results.txtresults'
  serialize(stream, encoding='utf-8', *, namespace_manager=None, **kwargs)

    return a text table of query results

    Parameters:

      - stream (`IO`)

      - encoding (`str`)

      - namespace_manager (`Optional`[`NamespaceManager`])

    Return type:

      `None`

## rdflib.plugins.sparql.results.xmlresults module

A Parser for SPARQL results in XML:

http://www.w3.org/TR/rdf-sparql-XMLres/

Bits and pieces borrowed from: http://projects.bigasterisk.com/sparqlhttp/

Authors: Drew Perttula, Gunnar Aastrand Grimnes

class rdflib.plugins.sparql.results.xmlresults.SPARQLXMLWriter(output, encoding='utf-8')

  Bases: `object`

  Python saxutils-based SPARQL XML Writer

  Parameters:

    - output (`IO`)

    - encoding (`str`)

  __dict__ = mappingproxy({'__module__': 'rdflib.plugins.sparql.results.xmlresults', '__doc__': '\n Python saxutils-based SPARQL XML Writer\n ', '__init__': <function SPARQLXMLWriter.__init__>, 'write_header': <function SPARQLXMLWriter.write_header>, 'write_ask': <function SPARQLXMLWriter.write_ask>, 'write_results_header': <function SPARQLXMLWriter.write_results_header>, 'write_start_result': <function SPARQLXMLWriter.write_start_result>, 'write_end_result': <function SPARQLXMLWriter.write_end_result>, 'write_binding': <function SPARQLXMLWriter.write_binding>, 'close': <function SPARQLXMLWriter.close>, '__dict__': <attribute '__dict__' of 'SPARQLXMLWriter' objects>, '__weakref__': <attribute '__weakref__' of 'SPARQLXMLWriter' objects>, '__annotations__': {}})
  __init__(output, encoding='utf-8')
    Parameters:

      - output (`IO`)

      - encoding (`str`)

  __module__ = 'rdflib.plugins.sparql.results.xmlresults'
  __weakref__

    list of weak references to the object

  close()
    Return type:

      `None`

  write_ask(val)
    Parameters:

      val (`bool`)

    Return type:

      `None`

  write_binding(name, val)
    Parameters:

      - name (`Variable`)

      - val (`Identifier`)

    Return type:

      `None`

  write_end_result()
    Return type:

      `None`

  write_header(allvarsL)
    Parameters:

      allvarsL (`Sequence`[`Variable`])

    Return type:

      `None`

  write_results_header()
    Return type:

      `None`

  write_start_result()
    Return type:

      `None`

class rdflib.plugins.sparql.results.xmlresults.XMLResult(source, content_type=None)

  Bases: `Result`

  Parameters:

    - source (`IO`)

    - content_type (`Optional`[`str`])

  __annotations__ = {}
  __init__(source, content_type=None)
    Parameters:

      - source (`IO`)

      - content_type (`Optional`[`str`])

  __module__ = 'rdflib.plugins.sparql.results.xmlresults'

class rdflib.plugins.sparql.results.xmlresults.XMLResultParser

  Bases: `ResultParser`

  __annotations__ = {}
  __module__ = 'rdflib.plugins.sparql.results.xmlresults'
  parse(source, content_type=None)

    return a Result object

    Parameters:

      - source (`IO`)

      - content_type (`Optional`[`str`])

    Return type:

      `Result`

class rdflib.plugins.sparql.results.xmlresults.XMLResultSerializer(result)

  Bases: `ResultSerializer`

  Parameters:

    result (`Result`)

  __annotations__ = {}
  __init__(result)
    Parameters:

      result (`Result`)

  __module__ = 'rdflib.plugins.sparql.results.xmlresults'
  serialize(stream, encoding='utf-8', **kwargs)

    return a string properly serialized

    Parameters:

      - stream (`IO`)

      - encoding (`str`)

      - kwargs (`Any`)

    Return type:

      `None`

rdflib.plugins.sparql.results.xmlresults.parseTerm(element)

  rdflib object (Literal, URIRef, BNode) for the given elementtree element

  Parameters:

    element (`Element`)

  Return type:

    `Union`[`URIRef`, `Literal`, `BNode`]

## Module contents

Parsers and serializers for SPARQL Result formats