From 57793a4107ac211d43959599019e006edb55a3fa Mon Sep 17 00:00:00 2001 From: Gunnar Aastrand Grimnes Date: Mon, 6 Feb 2017 15:04:53 +0100 Subject: dirty_reads flag for SPARQLStore don't commit before every read. --- rdflib/plugins/stores/sparqlstore.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/rdflib/plugins/stores/sparqlstore.py b/rdflib/plugins/stores/sparqlstore.py index 6a9be7fd..b55e7b49 100644 --- a/rdflib/plugins/stores/sparqlstore.py +++ b/rdflib/plugins/stores/sparqlstore.py @@ -476,9 +476,20 @@ class SPARQLUpdateStore(SPARQLStore): queryEndpoint=None, update_endpoint=None, sparql11=True, context_aware=True, - postAsEncoded=True, autocommit=True, + postAsEncoded=True, + autocommit=True, + dirty_reads=False, **kwds ): + """ + :param autocommit if set, the store will commit after every + writing operations. If False, we only make queries on the + server once commit is called. + + :param dirty_reads if set, we do not commit before reading. So you + cannot read what you wrote before manually calling commit. + + """ SPARQLStore.__init__( self, @@ -491,25 +502,26 @@ class SPARQLUpdateStore(SPARQLStore): self.postAsEncoded = postAsEncoded self.autocommit = autocommit + self.dirty_reads = dirty_reads self._edits = None def query(self, *args, **kwargs): - if not self.autocommit: + if not self.autocommit and not self.dirty_reads: self.commit() return SPARQLStore.query(self, *args, **kwargs) def triples(self, *args, **kwargs): - if not self.autocommit: + if not self.autocommit and not self.dirty_reads: self.commit() return SPARQLStore.triples(self, *args, **kwargs) def contexts(self, *args, **kwargs): - if not self.autocommit: + if not self.autocommit and not self.dirty_reads: self.commit() return SPARQLStore.contexts(self, *args, **kwargs) def __len__(self, *args, **kwargs): - if not self.autocommit: + if not self.autocommit and not self.dirty_reads: self.commit() return SPARQLStore.__len__(self, *args, **kwargs) -- cgit v1.2.1