IPython and Sparql


In [ ]:
from IPython.core.display import HTML
# http://stackoverflow.com/questions/24337235/using-ipython-notebook-with-rdflib-to-log-sparql-queries-and-results
HTML("<iframe src=http://stackoverflow.com/questions/24337235/using-ipython-notebook-with-rdflib-to-log-sparql-queries-and-results/ </iframe>")

In [ ]:
%%script bash
         arq --data dcam.ttl '
         PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
         PREFIX dcam:    <http://purl.org/dc/dcam/>
         PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>

         CONSTRUCT
         WHERE { ?s rdf:type ?o . }'

In [ ]:
myquery = """
          PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
          CONSTRUCT
          WHERE {?s rdf:type ?o}
          """

In [ ]:
def turtleme(myquery):
              import rdflib
              g = rdflib.Graph()
              g.parse('dcam.rdf')
              results = g.query(myquery)
              print results.serialize(format="turtle")

In [ ]:
turtleme('dcam.ttl', myquery)

In [ ]:

Survey of Pythonic tools for RDF and Linked Data programming


In [ ]:
from IPython.core.display import HTML
# http://michelepasin.org/blog/2011/02/24/survey-of-pythonic-tools-for-rdf-and-linked-data-programming/
HTML("<iframe src=http://michelepasin.org/blog/2011/02/24/survey-of-pythonic-tools-for-rdf-and-linked-data-programming/ </iframe>")

RDFLib


In [ ]:
from IPython.core.display import HTML
# https://github.com/RDFLib
HTML("<iframe src=https://github.com/RDFLib </iframe>")