Giter Site home page Giter Site logo

riccardotommasini / sparqlwrapper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rdflib/sparqlwrapper

0.0 2.0 0.0 807 KB

A wrapper for a remote SPARQL endpoint

Home Page: http://rdflib.github.io/sparqlwrapper

License: Other

Makefile 0.28% Python 98.75% Shell 0.96%

sparqlwrapper's Introduction

SPARQL Endpoint interface to Python

Build Status PyPi version

SPARQLWrapper is a simple Python wrapper around a SPARQL service to remotelly execute your queries. It helps in creating the query invokation and, possibly, convert the result into a more manageable format.

Installation

From PyPi:

$ pip install sparqlwrapper

From GitHub::

$ pip install git+https://github.com/rdflib/sparqlwrapper#egg=sparqlwrapper

From Debian

$ sudo apt-get install python-sparqlwrapper

Usage

Create an instance to execute your query:

from SPARQLWrapper import SPARQLWrapper, JSON

sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setQuery("""
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    SELECT ?label
    WHERE { <http://dbpedia.org/resource/Asturias> rdfs:label ?label }
""")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()

for result in results["results"]["bindings"]:
    print(result["label"]["value"])

Source code

The source distribution contains:

  • SPARQLWrapper: the Python library. You should copy the directory somewhere into your PYTHONPATH. Alternatively, you can also run the distutils scripts:

    python setup.py install

  • test: some unit and integrations tests

  • script: some scripts to run the library against some SPARQL endpoints.

License

The package is licensed under W3C license.

sparqlwrapper's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.