Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storage transactions in Redland's Python bindings?

I've currently skimming through the Python-bindings for Redland and haven't found a clean way to do transactions on the storage engine via it. I found some model-transactions within the low-level Redland module:

import RDF, Redland

storage = RDF.Storage(...)
model = RDF.Model(storage)
Redland.librdf_model_transaction_start(model._model)
try:
    # Do something
    Redland.librdf_model_transaction_commit(model._model)
    model.sync()
except:
    Redland.librdf_model_transaction_rollback(model._model)

Do these also translate down to the storage layer?

Thanks :-)

like image 203
Horst Gutmann Avatar asked Oct 14 '22 18:10

Horst Gutmann


1 Answers

Yes, this should work. There are no convenience functions for the model class in the python wrapper right now but they would be similar to what you wrote:

class Model(object):
  ...
  def transaction_start(self):
    return Redland.librdf_model_transaction_start(self._model) 
like image 62
dajobe Avatar answered Oct 20 '22 03:10

dajobe