RDFLib / sparqlwrapper

A wrapper for a remote SPARQL endpoint
https://sparqlwrapper.readthedocs.io/
Other
513 stars 121 forks source link

Raise `ValueError` when user selects incopatable formats #190

Open nicholascar opened 2 years ago

nicholascar commented 2 years ago

This code fails because RDF is not a valid response format for a SELECT query:

from SPARQLWrapper import SPARQLWrapper, RDF, JSON, XML
sparql = SPARQLWrapper('http://ja.dbpedia.org/sparql')
sparql.setQuery('select * where { ?x ?y ?z. } limit 1')
sparql.setReturnFormat(RDF)
results = sparql.query().convert()

The code should not fail but should raise a ValueError Exception and explain why.

nicholascar commented 2 years ago

@eggplants this is just re-issuing your Issue with better scope for resolution.

dgupta04 commented 2 years ago

@nicholascar Hi, here as a first time contributor! I tried my hands on this issue and am submitting a PR that solves it. Request you to please review it and share your thoughts on the same! Thanks!

ananya2711 commented 2 years ago

Pull request added #218 with the required changes as discussed.