Skip to content

Commit

Permalink
Now properly autocommitting. Trying this on the road from a tethered …
Browse files Browse the repository at this point in the history
…iPad didn't work out. :-)
  • Loading branch information
Jim McCusker committed May 26, 2015
1 parent 509d851 commit d217c3c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rdflib/plugins/stores/sparqlstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,8 @@ def add(self, spo, context=None, quoted=False):
else:
q = "INSERT DATA { %s }" % triple
self._transaction().append(q)
if self.autocommit:
self.commit()

def addN(self, quads):
""" Add a list of quads to the store. """
Expand All @@ -641,6 +643,8 @@ def addN(self, quads):
triples = ["%s %s %s ." % (x[0].n3(), x[1].n3(), x[2].n3()) for x in contexts[context]]
data.append("INSERT DATA { GRAPH <%s> { %s } }\n" % (context.identifier, '\n'.join(triples)))
self._transaction().extend(data)
if self.autocommit:
self.commit()

def remove(self, spo, context):
""" Remove a triple from the store """
Expand All @@ -663,6 +667,8 @@ def remove(self, spo, context):
else:
q = "DELETE { %s } WHERE { %s } " % (triple, triple)
self._transaction().append(q)
if self.autocommit:
self.commit()

def _do_update(self, update):
print update
Expand All @@ -672,8 +678,6 @@ def _do_update(self, update):
self.setRequestMethod(URLENCODED if self.postAsEncoded else POSTDIRECTLY)

result = SPARQLWrapper.query(self)
if self.autocommit:
self.commit()
return result

def update(self, query,
Expand Down Expand Up @@ -738,6 +742,8 @@ def update(self, query,
query = self.where_pattern.sub("WHERE { " + values, query)

self._transaction().append(query)
if self.autocommit:
self.commit()

def _insert_named_graph(self, query, query_graph):
"""
Expand Down

0 comments on commit d217c3c

Please sign in to comment.