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

Testing

In order for the tests to run, you must have the following Docker containers started:

docker run -d --name travis-virtuoso -p 8890:8890 -e SPARQL_UPDATE=true tenforce/virtuoso:1.2.0-virtuoso7.2.2
docker run -d -p 3030:3030 --name travis-fuseki -e ADMIN_PASSWORD=PASSWORD -e ENABLE_DATA_WRITE=true -e ENABLE_UPDATE=true -e ENABLE_UPLOAD=true secoresearch/fuseki

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.11.1a0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

aiosparql-0.11.1a0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file aiosparql-0.11.1a0.tar.gz.

File metadata

  • Download URL: aiosparql-0.11.1a0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

File hashes

Hashes for aiosparql-0.11.1a0.tar.gz
Algorithm Hash digest
SHA256 6619bc82557ce3707a48889bb9a08bd96058f639e64e0ade346bbd7fe2e252bb
MD5 6667e501a0a9f465358fceb02e684bcb
BLAKE2b-256 8106dcee263b6880d453e0c4e1e9f10d7f171577bccce433dbb3ec687c08caaf

See more details on using hashes here.

Provenance

File details

Details for the file aiosparql-0.11.1a0-py3-none-any.whl.

File metadata

  • Download URL: aiosparql-0.11.1a0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

File hashes

Hashes for aiosparql-0.11.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 fecc297a859a1169f4269e77c7073fcf4373a511dd7340d2b83e13a66f45b422
MD5 b74a9cf198c01f5e03a0407c0f015c7b
BLAKE2b-256 58da445083bb9d509549567112fce52d0ca56107cd26037256da8b187f6e3603

See more details on using hashes here.

Provenance

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