The store module is the gatekeeper for populating and maintaining the RDF store db.
Add an RDF graph to the store.
Parameter: | graph_tuple (tuple) – (url,raw_rdf) |
---|
Return the dc:identifier from a graph, given its location
Parameter: | graph (rdflib.graph.Graph) – an input RDF graph |
---|---|
Return type: | rdflib.URIRef.URIRef |
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]