Redland的Python绑定中的存储事务?

2024-06-28 20:43:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前浏览了Redland的Python绑定,还没有找到一种通过它在存储引擎上执行事务的干净方法。我在低层Redland模块中发现了一些模型事务:

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)

这些也会转化到存储层吗?在

谢谢:-)


Tags: 模块方法模型引擎importmodelstoragerdf
1条回答
网友
1楼 · 发布于 2024-06-28 20:43:19

是的,这应该行得通。目前在python包装器中没有模型类的方便函数,但它们与您编写的类似:

class Model(object):
  ...
  def transaction_start(self):
    return Redland.librdf_model_transaction_start(self._model) 

相关问题 更多 >