rdflib.plugins.stores package

Submodules

rdflib.plugins.stores.auditable module

This wrapper intercepts calls through the store interface and implements thread-safe logging of destructive operations (adds / removes) in reverse. This is persisted on the store instance and the reverse operations are executed In order to return the store to the state it was when the transaction began Since the reverse operations are persisted on the store, the store itself acts as a transaction.

Calls to commit or rollback, flush the list of reverse operations This provides thread-safe atomicity and isolation (assuming concurrent operations occur with different store instances), but no durability (transactions are persisted in memory and wont be available to reverse operations after the system fails): A and I out of ACID.

class rdflib.plugins.stores.auditable.AuditableStore(store)[source]

Bases: rdflib.store.Store

__annotations__ = {}
__init__(store)[source]

identifier: URIRef of the Store. Defaults to CWD configuration: string containing infomation open can use to connect to datastore.

__len__(context=None)[source]

Number of statements in the store. This should only account for non- quoted (asserted) statements if the context is not specified, otherwise it should return the number of statements in the formula or context given.

Parameters:

context – a graph instance to query or None

__module__ = 'rdflib.plugins.stores.auditable'
add(triple, context, quoted=False)[source]

Adds the given statement to a specific context or to the model. The quoted argument is interpreted by formula-aware stores to indicate this statement is quoted/hypothetical It should be an error to not specify a context and have the quoted argument be True. It should also be an error for the quoted argument to be True when the store is not formula-aware.

bind(prefix, namespace)[source]
close(commit_pending_transaction=False)[source]

This closes the database connection. The commit_pending_transaction parameter specifies whether to commit all pending transactions before closing (if the store is transactional).

commit()[source]
contexts(triple=None)[source]

Generator over all contexts in the graph. If triple is specified, a generator over all contexts the triple is in.

if store is graph_aware, may also return empty contexts

Returns:

a generator over Nodes

destroy(configuration)[source]

This destroys the instance of the store identified by the configuration string.

namespace(prefix)[source]
namespaces()[source]
open(configuration, create=True)[source]

Opens the store specified by the configuration string. If create is True a store will be created if it does not already exist. If create is False and a store does not already exist an exception is raised. An exception is also raised if a store exists, but there is insufficient permissions to open the store. This should return one of: VALID_STORE, CORRUPTED_STORE, or NO_STORE

prefix(namespace)[source]
query(*args, **kw)[source]

If stores provide their own SPARQL implementation, override this.

queryGraph is None, a URIRef or ‘__UNION__’ If None the graph is specified in the query-string/object If URIRef it specifies the graph to query, If ‘__UNION__’ the union of all named graphs should be queried (This is used by ConjunctiveGraphs Values other than None obviously only makes sense for context-aware stores.)

remove(xxx_todo_changeme, context=None)[source]

Remove the set of triples matching the pattern from the store

rollback()[source]
triples(triple, context=None)[source]

A generator over all the triples matching the pattern. Pattern can include any objects for used for comparing against nodes in the store, for example, REGEXTerm, URIRef, Literal, BNode, Variable, Graph, QuotedGraph, Date? DateRange?

Parameters:

context – A conjunctive query can be indicated by either

providing a value of None, or a specific context can be queries by passing a Graph instance (if store is context aware).

rdflib.plugins.stores.concurrent module

class rdflib.plugins.stores.concurrent.ConcurrentStore(store)[source]

Bases: object

__dict__ = mappingproxy({'__module__': 'rdflib.plugins.stores.concurrent', '__init__': <function ConcurrentStore.__init__>, 'add': <function ConcurrentStore.add>, 'remove': <function ConcurrentStore.remove>, 'triples': <function ConcurrentStore.triples>, '__len__': <function ConcurrentStore.__len__>, '_ConcurrentStore__begin_read': <function ConcurrentStore.__begin_read>, '_ConcurrentStore__end_read': <function ConcurrentStore.__end_read>, '__dict__': <attribute '__dict__' of 'ConcurrentStore' objects>, '__weakref__': <attribute '__weakref__' of 'ConcurrentStore' objects>, '__doc__': None, '__annotations__': {}})
__init__(store)[source]
__len__()[source]
__module__ = 'rdflib.plugins.stores.concurrent'
__weakref__

list of weak references to the object (if defined)

add(triple)[source]
remove(triple)[source]
triples(triple)[source]
class rdflib.plugins.stores.concurrent.ResponsibleGenerator(gen, cleanup)[source]

Bases: object

A generator that will help clean up when it is done being used.

__del__()[source]
__init__(gen, cleanup)[source]
__iter__()[source]
__module__ = 'rdflib.plugins.stores.concurrent'
__next__()[source]
__slots__ = ['cleanup', 'gen']
cleanup
gen

rdflib.plugins.stores.regexmatching module

This wrapper intercepts calls through the store interface which make use of the REGEXTerm class to represent matches by REGEX instead of literal comparison.

Implemented for stores that don’t support this and essentially provides the support by replacing the REGEXTerms by wildcards (None) and matching against the results from the store it’s wrapping.

class rdflib.plugins.stores.regexmatching.REGEXMatching(storage)[source]

Bases: rdflib.store.Store

__annotations__ = {}
__init__(storage)[source]

identifier: URIRef of the Store. Defaults to CWD configuration: string containing infomation open can use to connect to datastore.

__len__(context=None)[source]

Number of statements in the store. This should only account for non- quoted (asserted) statements if the context is not specified, otherwise it should return the number of statements in the formula or context given.

Parameters:

context – a graph instance to query or None

__module__ = 'rdflib.plugins.stores.regexmatching'
add(triple, context, quoted=False)[source]

Adds the given statement to a specific context or to the model. The quoted argument is interpreted by formula-aware stores to indicate this statement is quoted/hypothetical It should be an error to not specify a context and have the quoted argument be True. It should also be an error for the quoted argument to be True when the store is not formula-aware.

bind(prefix, namespace)[source]
close(commit_pending_transaction=False)[source]

This closes the database connection. The commit_pending_transaction parameter specifies whether to commit all pending transactions before closing (if the store is transactional).

commit()[source]
contexts(triple=None)[source]

Generator over all contexts in the graph. If triple is specified, a generator over all contexts the triple is in.

if store is graph_aware, may also return empty contexts

Returns:

a generator over Nodes

destroy(configuration)[source]

This destroys the instance of the store identified by the configuration string.

namespace(prefix)[source]
namespaces()[source]
open(configuration, create=True)[source]

Opens the store specified by the configuration string. If create is True a store will be created if it does not already exist. If create is False and a store does not already exist an exception is raised. An exception is also raised if a store exists, but there is insufficient permissions to open the store. This should return one of: VALID_STORE, CORRUPTED_STORE, or NO_STORE

prefix(namespace)[source]
remove(triple, context=None)[source]

Remove the set of triples matching the pattern from the store

remove_context(identifier)[source]
rollback()[source]
triples(triple, context=None)[source]

A generator over all the triples matching the pattern. Pattern can include any objects for used for comparing against nodes in the store, for example, REGEXTerm, URIRef, Literal, BNode, Variable, Graph, QuotedGraph, Date? DateRange?

Parameters:

context – A conjunctive query can be indicated by either

providing a value of None, or a specific context can be queries by passing a Graph instance (if store is context aware).

class rdflib.plugins.stores.regexmatching.REGEXTerm(expr)[source]

Bases: str

REGEXTerm can be used in any term slot and is interpreted as a request to perform a REGEX match (not a string comparison) using the value (pre-compiled) for checking rdf:type matches

__dict__ = mappingproxy({'__module__': 'rdflib.plugins.stores.regexmatching', '__doc__': '\n    REGEXTerm can be used in any term slot and is interpreted as a request to\n    perform a REGEX match (not a string comparison) using the value\n    (pre-compiled) for checking rdf:type matches\n    ', '__init__': <function REGEXTerm.__init__>, '__reduce__': <function REGEXTerm.__reduce__>, '__dict__': <attribute '__dict__' of 'REGEXTerm' objects>, '__weakref__': <attribute '__weakref__' of 'REGEXTerm' objects>, '__annotations__': {}})
__init__(expr)[source]
__module__ = 'rdflib.plugins.stores.regexmatching'
__reduce__()[source]

Helper for pickle.

__weakref__

list of weak references to the object (if defined)

rdflib.plugins.stores.regexmatching.regexCompareQuad(quad, regexQuad)[source]

rdflib.plugins.stores.sparqlconnector module

rdflib.plugins.stores.sparqlstore module

Module contents

This package contains modules for additional RDFLib stores