本文介绍了RDFlib“磁盘"存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过 2 天的研究,我(一个新手)仍然无法弄清楚 RDFFlib 3.1.0 中有哪些磁盘上"存储可用.如果你有一个有效的例子,那会很高兴看到......对于我的应用程序,我更喜欢 SQLite.我不需要访问在线 RDF 商店,我想在 RDF 中存储有关组织内部关系的信息.谢谢

After 2 days of research I (a newby) still can't figure out what 'on disk' stores are available in RDFFlib 3.1.0. If you have a working example, that would be nice to see...For my app I prefer SQLite. I need no access to online RDF stores, I want to store info about relations inside the organisation in RDF.Thanks

推荐答案

这里有一个例子来让它与 MySQL 一起工作.我认为 rdflib 3 不适用于 SQLite.

Here you have an example to make it work with MySQL. I don't think rdflib 3 works with SQLite.

    import rdflib
    from rdflib.Graph import ConjunctiveGraph as Graph
    from rdflib import plugin
    from rdflib.store import Store, NO_STORE, VALID_STORE

    configString = "host=localhost,user=root,password=,db=db_name"
    rt = store.open(configString,create=False)
    assert rt == VALID_STORE,"The store is corrupted"
    print "load store success"
    graph = Graph(store)
    g.parse("some.rdf")
    g.commit()

我会避免使用 rdflib 的磁盘存储,因为它们似乎不太可靠并且扩展性不是很好.正如您所注意到的,文档也不是很好.

I would avoid rdflib's on-disk stores since they seem to be not very reliable and don't scale very well. As you have noticed the documentation is not great either.

如果您正在做一些严肃的工作,那么请使用 Virtuoso 或 4store 之类的三重存储,并使用 SPARQL 访问数据.有许多库可以使用 Python 访问它们.

If you are doing some serious work then go for triple stores like Virtuoso or 4store and use SPARQL to access the data. There are many libraries to access them with Python.

这篇关于RDFlib“磁盘"存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-21 10:42