Skip to main content

An asynchronous SPARQL library using aiohttp

Project description

License Build Status Code Coverage

An asynchronous SPARQL library using aiohttp

Synopsis

from aiosparql.syntax import (
    IRI, Namespace, Node, PrefixedName, RDF, RDFTerm, Triples)

# define a namespace

class Boo(Namespace):
    __iri__ = IRI("http://boo#")
    SomeClass = PrefixedName
    website = PrefixedName
    label = PrefixedName

# create a node

node = Node("<subject>", {
    RDF.type: Boo.SomeClass,
    Boo.website: IRI("http://example.org"),
    Boo.label: "some label", # "some label" will be automatically escaped
})

# missing prefixed names will show on your IDE and fail on execution

print(Boo.something) # AttributeError!

# create triples

triples = Triples([("s", "p", "o")]) # o is automatically escaped
triples.append(("s", Boo.website, IRI("http://example.org")))
triples.extend([("s", Boo.website, IRI("http://example.org"))])

print(triples) # print the triples is a format usable directly in a SPARQL
               # query. It also groups by subject automatically for you


from aiosparql.client import SPARQLClient

client = SPARQLClient("http://dbpedia.org/sparql")
result = await client.query("select * where {?s ?p ?o} limit 1")
# result is a dict of the JSON result
result = await client.update("""
    with {{graph}}
    insert data {
        {{}}
    }
    """, triples)
# the triples will be automatically indented to produce a beautiful query


from aiosparql.escape import escape_any

print(escape_any(True)) # "true"
print(escape_any("foo")) # "foo"
print(escape_any(5)) # "5"
print(escape_any(5.5)) # "5.5"^^xsd:double

Installation

  • User space installation

    easy_install --user aiosparql
  • System wide installation

    easy_install aiosparql

Requirements

  • Python >= 3.5

Credits

This software has been produced by Dacota One.

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

aiosparql-0.10.0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiosparql-0.10.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file aiosparql-0.10.0.tar.gz.

File metadata

  • Download URL: aiosparql-0.10.0.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiosparql-0.10.0.tar.gz
Algorithm Hash digest
SHA256 cd6d0c3291a720a784ba4ec674f80e455bf6d5f5c5599ed637d06f96c6b9c5f7
MD5 2aee312d3d412966b1f98587c305b7d8
BLAKE2b-256 606ef580aed9dd7234d52ca311bee671a3e202ece61c5e6299e78d4cd42d7dc6

See more details on using hashes here.

File details

Details for the file aiosparql-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiosparql-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1e9dec27d8949aee741de6f00b04b55cdbdae14d5527da92004eaf53a98b614
MD5 7cb046b2cc92514a1337f824587815db
BLAKE2b-256 936a210e1c3bf2169830f6570974850faa8ec411db5cc5ae7ff54d15e33b7b08

See more details on using hashes here.

Supported by

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