RDFLib/rdflib-sparql — pull request #11 by uholzer (2013-02-27 15:57:38+00:00)
Title: initNs and initBindings for processUpdate and prepareQuery

Currently, it is not possible to declare namespaces and bind variables outside the SPARQL query when using processUpdate or prepareQuery. This pull requests adds the arguments `initNs` and `initBindings` to these two functions. Then, one can do things like this:
```python
from rdflib import Graph, URIRef
from rdflib_sparql.processor import processUpdate, prepareQuery

g = Graph()
g.add((URIRef("http://foo"), URIRef("http://prop"), URIRef("http://bar")))

processUpdate(
g,
"INSERT { ?a ?newprop ns:baz } WHERE { ?a ?b ?c }",
initNs={"ns": URIRef("http://")},
initBindings={"?newprop": URIRef("http://newprop")}
)

print("After update:")
for t in g.triples((None,None,None)):
print(t)

q = prepareQuery(
"select ?c where { ns:foo ?newprop ?c }",
initNs={"ns": URIRef("http://")}
)

print("Query result:")
for row in g.query(q, initBindings={"?newprop": URIRef("http://newprop")}):
print(row)
```