RDFLib/rdflib — pull request #292 by uholzer (2013-05-24 16:08:30+00:00)
Title: initNs and initBindings in SPARQLWrapper.update

This fixes #289, I hope. Tests should still be added, so maybe don't merge yet. Adding some documentation describing the behaviour wouldn't hurt either.

It turned out to be easier than I thought. Adding prefixes is trivial of course. Supporting bindings is done through VALUEs similarly to SPARQLWrapper.query. But for updates, the VALUEs must be added to the WHERE block. Luckily, the SPARQL grammar for updates requires a WHERE clause whenever variables can be used, and it forbids WHERE clauses for operations not supporting variables.

There is only one obvious problem: Should a literal contain `WHERE {`, it screws up.