Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

query a fuseki server using python (or something)

Tags:

rdf

sparql

fuseki

I'm trying to issue a complicated query against a fuseki server that I'm running locally through a browser but it keeps crashing- is it possible to do it through a python script? If so- how?

like image 266
smatthewenglish Avatar asked Feb 08 '23 00:02

smatthewenglish


1 Answers

You can use any suitable command line tool, for example curl:

curl http://localhost:3030/your_service/sparql --data 'query=ASK { ?s ?p ?o . }'

If you want to use Python specifically, you can use SPARQLWrapper, or just the Requests package.

Example using Requests:

import requests
response = requests.post('http://localhost:3030/your_service/sparql',
       data={'query': 'ASK { ?s ?p ?o . }'})
print(response.json())
like image 151
evsheino Avatar answered Mar 08 '23 02:03

evsheino