Skip to main content

A library for parsing SPARQL queries and updates

Project description

SARI Sparql Parser

A parser for SPARQL queries and updates.

Note: This parser is very experimental and may not function very reliably.

Installation

install using pip

pip install sari-sparql-parser

Usage

Parse a SPARQL query:

from sariSparqlParser import parser

query = """PREFIX crm: <http://www.cidoc-crm.org/cidoc/crm>
    SELECT ?subject ?identifier WHERE {
        ?subject crm:P1_is_identified_by ?identifier .
        ?identifier a ?type .
        VALUES (?type) {
            (crm:E41_Appellation)
            (crm:E42_Identifier)
        }
    }
"""
p = parser()
p.parseQuery(query)

This will output:

{
    'prefixes': {'crm': 'http://www.cidoc-crm.org/cidoc/crm'},
    'select': ['subject', 'identifier'],
    'where': [{
        's': {'type': rdflib.term.Variable, 'value': 'subject'},
        'p': {'type': rdflib.term.URIRef, 'value': 'http://www.cidoc-crm.org/cidoc/crmP1_is_identified_by'},
        'o': {'type': rdflib.term.Variable, 'value': 'identifier'}
    },
    {
        's': {'type': rdflib.term.Variable, 'value': 'identifier'},
        'p': {'type': rdflib.term.URIRef, 'value': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'},
        'o': {'type': rdflib.term.Variable, 'value': 'type'}
    }],
    'values': [{
        'type': {'type': rdflib.term.URIRef, 'value': 'http://www.cidoc-crm.org/cidoc/crmE41_Appellation'}
    },
    {
        'type': {'type': rdflib.term.URIRef,'value': 'http://www.cidoc-crm.org/cidoc/crmE42_Identifier'}
    }]
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sari-sparql-parser-0.0.5.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

sari_sparql_parser-0.0.5-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file sari-sparql-parser-0.0.5.tar.gz.

File metadata

  • Download URL: sari-sparql-parser-0.0.5.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.1

File hashes

Hashes for sari-sparql-parser-0.0.5.tar.gz
Algorithm Hash digest
SHA256 b8b36d016b41e47d1a7ba563d60c68d4904322b8ba3bc8cb3453acbb6d70a8bb
MD5 07e1f45be2c9ed37da14105ee12970ed
BLAKE2b-256 9db743ee8fa64b1b6ce44da7c4168dce12acce42a9732994c22a2584db2551fe

See more details on using hashes here.

File details

Details for the file sari_sparql_parser-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: sari_sparql_parser-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.1

File hashes

Hashes for sari_sparql_parser-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 637f584550f8cc094d0cc9e76bcc89e99f3b38890b808543812312f1b4bc2e0c
MD5 e5e33896842ce668168b0a5a2f43a6ad
BLAKE2b-256 9b4e093e8c20ec5e42b018faaacbd1152b0c547f8f33bd5dccd1928c71f5b6a7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page