Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Runs a sparql query on dbpedia
#!/bin/env python3
## usage: ./sparql_query.py 'select ?x where {[] a ?x} limit 100'
import json
import sys
from SPARQLWrapper import SPARQLWrapper, JSON
if __name__ == '__main__':
query = sys.argv[1]
sparql = SPARQLWrapper('http://dbpedia.org/sparql')
sparql.setQuery(query)
sparql.setReturnFormat(JSON)
print(json.dumps(sparql.query().convert()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment