summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Aastrand Grimnes <gromgull@gmail.com>2017-02-06 15:04:53 +0100
committerGunnar Aastrand Grimnes <gromgull@gmail.com>2017-02-09 09:07:27 +0100
commit57793a4107ac211d43959599019e006edb55a3fa (patch)
tree6ef78396b19575a6d6ae3638eef2d83ab5cc4253
parentf7c7be3d46fc81e4515a7aac8911e7aabaeee071 (diff)
downloadrdflib-57793a4107ac211d43959599019e006edb55a3fa.tar.gz
dirty_reads flag for SPARQLStore
don't commit before every read.
-rw-r--r--rdflib/plugins/stores/sparqlstore.py22
1 files 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)