added UPDATE example
@@ -66,8 +66,67 @@ Variables can also be pre-bound, using the ``initBindings`` kwarg which can
pass in a ``dict`` of initial bindings. This is particularly
useful for prepared queries, as described below.
-Quering a Remote Service
-^^^^^^^^^^^^^^^^^^^^^^^^
+Update Queries
+^^^^^^^^^^^^^^
+
+Update queries are performed just like reading queries but using the :meth:`rdflib.graph.Graph.update` method. An
+example:
+
+.. code-block:: python
+
+ from rdflib import Graph
+
+ # Create a Graph, add in some test data
+ g = Graph()
+ g.parse(
+ data="""
+ <x:> a <c:> .
+ <y:> a <c:> .
+ """,
+ format="turtle"
+ )
+
+ # Select all the things (s) that are of type (rdf:type) c:
+ qres = g.query("""SELECT ?s WHERE { ?s a <c:> }""")
+
+ for row in qres:
+ print(f"{row.s}")
+ # prints:
+ # x:
+ # y:
+
+ # Add in a new triple using SPATQL UPDATE
+ g.update("""INSERT DATA { <z:> a <c:> }""")
+
+ # Select all the things (s) that are of type (rdf:type) c:
+ qres = g.query("""SELECT ?s WHERE { ?s a <c:> }""")
+
+ print("After update:")
+ for row in qres:
+ print(f"{row.s}")
+ # prints:
+ # x:
+ # y:
+ # z:
+
+ # Change type of <y:> from <c:> to <d:>
+ g.update("""
+ DELETE { <y:> a <c:> }
+ INSERT { <y:> a <d:> }
+ WHERE { <y:> a <c:> }
+ """)
+ print("After second update:")
+ qres = g.query("""SELECT ?s ?o WHERE { ?s a ?o }""")
+ for row in qres:
+ print(f"{row.s} a {row.o}")
+ # prints:
+ # x: a c:
+ # z: a c:
+ # y: a d:
+
+
+Querying a Remote Service
+^^^^^^^^^^^^^^^^^^^^^^^^^
The ``SERVICE`` keyword of SPARQL 1.1 can send a query to a remote SPARQL endpoint.
