sparql

How can I insert variable into SPARQL query?

How can I insert variable into SPARQL query? Question: I use the rdflib library. I need to insert a variable into a SPARQL query. I do this: q = prepareUpdate("""INSERT DATA { <r> a <owl:Ontology> }""") g.update(q, initBindings={‘r’: uri}) uri = ‘http://www.example.org/ontologies/example/example.owl’ g – object class Graph() Output result: <r:> a <owl:Ontology> . Required result: …

Total answers: 1

Fetching triples using SPARQL query from turtle file

Fetching triples using SPARQL query from turtle file Question: I am new to SPARQL and currently struglling to fetch triples from a turtle file. ### https://ontology/1001 <https://ontology/1001> rdf:type owl:Class ; rdfs:subClassOf <https://ontology/748>; <http://www.geneontology.org/formats/oboInOwl#hasExactSynonym> "Injury, neuronal" , "Neurotrauma" ; rdfs:label "Nervous system injury" . ### https://ontology/10021 <https://ontology/10021> rdf:type owl:Class ; rdfs:subClassOf <https://ontology/2034> ; rdfs:label "C3 glomerulopathy" …

Total answers: 1

Inserting Python Variable in Sparql

Inserting python variable in SPARQL Question: I have a string variable I want to pass in my SPARQL query and I can’t get it to work. title = ‘Good Will Hunting’ [str(s) for s, in graph.query(”’ PREFIX ddis: <http://ddis.ch/atai/> PREFIX wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX schema: <http://schema.org/> SELECT ?lbl WHERE { ?movie rdfs:label $title@en …

Total answers: 1

Read Turtle file and query the graph using SPARQL

Read Turtle file and query the graph using SPARQL Question: I am in a learning phase of SPARQL so excuse if the question sounds basic. I am exploring SPARQLWrapper to connect to a SPARQL endpoint to fetch some data. Below is the query. sparql = SPARQLWrapper("http://patho.phenomebrowser.net/sparql/") #endpoint link sparql.setQuery(""" PREFIX SIO: <http://semanticscience.org/resource/SIO_> PREFIX RO: <http://purl.obolibrary.org/obo/RO_> …

Total answers: 1

How can we use a python string variable in a SPARQL query?

How can we use a python string variable in a SPARQL query? Question: I want to use python string variables in my SPARQL query without an IRI (for the sake of looping through a list of variables etc. I tried the code below but it doesn’t seem to work. Please ignore the prefixes etc. I …

Total answers: 2