加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

Redland的Python绑定存储事务?

发布时间:2020-12-16 22:25:42 所属栏目:Python 来源:网络整理
导读:我目前正在浏览Redland的Python绑定,并且还没有找到一种通过它在存储引擎上进行事务处理的简洁方法.我在低级Redland模块中发现了一些模型事务: import RDF,Redlandstorage = RDF.Storage(...)model = RDF.Model(storage)Redland.librdf_model_transaction_s

我目前正在浏览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)

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

谢谢 :-)

最佳答案
是的,这应该有效. python包装器中的模型类没有便利函数,但它们与您编写的类似:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读