Table Of Contents

Previous topic

Graph Manager

Next topic

Miscellaneous Utilities

This Page

Store

The store module is the gatekeeper for populating and maintaining the RDF store db.

eltk.store.store.addToStore(rdf_tuple)

Add an RDF graph to the store.

Parameter:graph_tuple (tuple) – (url,raw_rdf)
eltk.store.store.getIdentifier(graph)

Return the dc:identifier from a graph, given its location

Parameter:graph (rdflib.graph.Graph) – an input RDF graph
Return type:rdflib.URIRef.URIRef

How to use store

First create simple store with rdflib:

>>> store = plugin.get('MySQL', Store)() #('GOLDComms_id')

You must convert the config string to one compatible with rdflib:

>>> rdflib_config_string = 'host='+STORE_CONFIG['host']+',user='+STORE_CONFIG['user']+',password='+STORE_CONFIG['password']+',db='+STORE_CONFIG['db']

Open the store:

>>> store.open(rdflib_config_string, create=False)

Create a conjunctive graph using the store:

>>> cg = ConjunctiveGraph(store)
>>> print len(cg)

Show the results:

>>> results = sparqlQuery('SELECT  ?o WHERE {<http://purl.org/linguistics/gold/%s> rdfs:comment ?o }' % 'VerbPhrase',cg)

>>> for r in results:
>>>    print r[0]

Store Utils

This utils module contains various useful functions concerning the store.

eltk.store.utils.resetDB(dbconfig)

Reset a db and create a schema for the store.

Parameter:dbconfig (dict) – a config dict