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

发布于 2024-07-07 21:31:47 字数 453 浏览 7 评论 0原文

我目前已经浏览了 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)

这些也可以转化为存储层吗?

谢谢 :-)

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 :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白日梦 2024-07-14 21:31:47

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

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

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) 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文