Skip to main content

An asynchronous SPARQL library using aiohttp

Project description

License Build Status Code Coverage

An asynchronous SPARQL library using aiohttp


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, IRI(""),
    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",, IRI("")))
triples.extend([("s",, IRI(""))])

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("")
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


  • User space installation

    easy_install --user aiosparql
  • System wide installation

    easy_install aiosparql


  • Python >= 3.5


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.

Filename, size & hash SHA256 hash help File type Python version Upload date
aiosparql-0.10.1-py3-none-any.whl (11.2 kB) Copy SHA256 hash SHA256 Wheel py3
aiosparql-0.10.1.tar.gz (16.6 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page