Skip to main content

SPARQL semantic translator and ORM for Python.

Project description

sparqly

SPARQL semantic translator and object-mapper for Python (wip).

Example

We define a query object as an instance of sparqly.Item, with the predicates listed as attributes following the idiom of pretty_name = "actual name". For example, to query Pre-Raphaelite aritsts on WikiData, the schema we define could look like

from sparqly import Item

class Artist(Item):
  movement      = "wdt:P135"
  instance_of   = "wdt:P31"

We can then generate the query text for a selection with

from sparqly import query

q = query()
q.select(Artist).where(
  movement = "wd:Q184814", # pre-raphaelite
  instance_of = "wd:Q5"    # human
)

print(q.all())

Which will print to the console:

SELECT ?Artist WHERE {
	?Artist wdt:P135 wd:Q184814 ;
	wdt:P31 wd:Q5 .
}

Changelog

Version 0.1.0:

  • Object-Relational-Mapping (ORM)
  • SELECT
  • WHERE

Planned Features

  • Ability to attach service
  • CONSTRUCT/ASK/DESCRIBE
  • Filters like ORDER, LIMIT, GROUP
  • More semantic support
  • Additional methods for constructing queries depending on circumstance and complexity

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

sparqly-0.1.1.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

sparqly-0.1.1-py3-none-any.whl (16.2 kB view hashes)

Uploaded Python 3

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