diff --git a/python/src/memory_store.rs b/python/src/memory_store.rs
index a63bb0b1..26f0e6df 100644
--- a/python/src/memory_store.rs
+++ b/python/src/memory_store.rs
@@ -176,6 +176,43 @@ impl PyMemoryStore {
query_results_to_python(py, results)
}
+ /// Executes a `SPARQL 1.1 update `_.
+ ///
+ /// :param update: the update to execute
+ /// :type update: str
+ /// :raises SyntaxError: if the provided update is invalid
+ ///
+ /// The `LOAD operation `_ is not supported yet.
+ /// The store does not track the existence of empty named graphs.
+ /// This method has no ACID guarantees.
+ ///
+ /// ``INSERT DATA`` update:
+ ///
+ /// >>> store = MemoryStore()
+ /// >>> store.update('INSERT DATA { "1" }')
+ /// >>> list(store)
+ /// [ predicate= object=> graph_name=>]
+ ///
+ /// ``DELETE DATA`` update:
+ ///
+ /// >>> store = MemoryStore()
+ /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')))
+ /// >>> store.update('DELETE DATA { "1" }')
+ /// >>> list(store)
+ /// []
+ ///
+ /// ``DELETE`` update:
+ ///
+ /// >>> store = MemoryStore()
+ /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')))
+ /// >>> store.update('DELETE WHERE { ?p ?o }')
+ /// >>> list(store)
+ /// []
+ #[text_signature = "($self, update)"]
+ fn update(&self, update: &str) -> PyResult<()> {
+ self.inner.update(update).map_err(map_evaluation_error)
+ }
+
/// Loads an RDF serialization into the store
///
/// It currently supports the following formats:
diff --git a/python/src/sled_store.rs b/python/src/sled_store.rs
index 7a3282c6..4d9a818c 100644
--- a/python/src/sled_store.rs
+++ b/python/src/sled_store.rs
@@ -191,6 +191,44 @@ impl PySledStore {
query_results_to_python(py, results)
}
+ /// Executes a `SPARQL 1.1 update `_.
+ ///
+ /// :param update: the update to execute
+ /// :type update: str
+ /// :raises SyntaxError: if the provided update is invalid
+ /// :raises IOError: if an I/O error happens while reading the store
+ ///
+ /// The `LOAD operation `_ is not supported yet.
+ /// The store does not track the existence of empty named graphs.
+ /// This method has no ACID guarantees.
+ ///
+ /// ``INSERT DATA`` update:
+ ///
+ /// >>> store = MemoryStore()
+ /// >>> store.update('INSERT DATA { "1" }')
+ /// >>> list(store)
+ /// [ predicate= object=> graph_name=>]
+ ///
+ /// ``DELETE DATA`` update:
+ ///
+ /// >>> store = MemoryStore()
+ /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')))
+ /// >>> store.update('DELETE DATA { "1" }')
+ /// >>> list(store)
+ /// []
+ ///
+ /// ``DELETE`` update:
+ ///
+ /// >>> store = MemoryStore()
+ /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')))
+ /// >>> store.update('DELETE WHERE { ?p ?o }')
+ /// >>> list(store)
+ /// []
+ #[text_signature = "($self, update)"]
+ fn update(&self, update: &str) -> PyResult<()> {
+ self.inner.update(update).map_err(map_evaluation_error)
+ }
+
/// Loads an RDF serialization into the store
///
/// It currently supports the following formats:
diff --git a/python/tests/test_store.py b/python/tests/test_store.py
index af6ddc11..99b1f0f4 100644
--- a/python/tests/test_store.py
+++ b/python/tests/test_store.py
@@ -146,6 +146,23 @@ class TestAbstractStore(unittest.TestCase, ABC):
)
self.assertEqual(len(list(results)), 2)
+ def test_update_insert_data(self):
+ store = self.store()
+ store.update('INSERT DATA { }')
+ self.assertEqual(len(store), 1)
+
+ def test_update_delete_data(self):
+ store = self.store()
+ store.add(Quad(foo, foo, foo))
+ store.update('DELETE DATA { }')
+ self.assertEqual(len(store), 0)
+
+ def test_update_delete_where(self):
+ store = self.store()
+ store.add(Quad(foo, foo, foo))
+ store.update('DELETE WHERE { ?v ?v ?v }')
+ self.assertEqual(len(store), 0)
+
def test_load_ntriples_to_default_graph(self):
store = self.store()
store.load(