Using Python rdflib: how to include literals in sparql queries?
I can include URIs and variables in my queries, but I can't include literals in my queries. Here, I have some code which successfully reads an RDF file, finds all the RDF triples with skos:prefLabels, counts them, and then identifies a couple of specific ones from a set of keywords: import rdflib.plugins.sparql as sparql import rdflib import rdflib.graph as g graph = g.Graph() # Read the RDF file graph.parse( 'h:\......SKOSTaxonomy.rdf', format='xml') # Build and execute the query q = sparql.prepareQuery('SELECT ?s ?p ?o WHERE { ?s ?p ?o .}') p = rdflib.URIRef("http://www.w3.org/2004/02/skos