Skip to content

SPARQL semantic translator and abstraction for Python.

License

Notifications You must be signed in to change notification settings

fjebaker/sparqly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

SPARQL semantic translator and abstraction for Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages