Module sqltriples :: Class TripleStore
[show private | hide private]
[frames | no frames]

Class TripleStore


A triple store whose contents are stored in an SQL-accessible database table.
Method Summary
  __init__(self, adapter, context, table_name, sequence_name, debug)
Initialise access to the store via the given 'adapter' and employing the given, optional 'context' URI, using a table with the given, optional 'table_name' ("triples" by default) and a sequence (for BNode generation) with the optional 'sequence_name' ("bnode" by default).
  add(self, pattern)
Add a triple using the information found in the given 'pattern'.
  close(self)
Close the connection to the database system.
  commit(self)
Commit the changes made to the triple store.
  contexts(self)
Return a list of contexts found in this store.
  count(self, pattern)
Return a count of the triples conforming to the given 'pattern'.
  delete(self)
Drop the store's table and sequence.
  delete_sequence(self)
Drop the BNode sequence.
  delete_table(self)
Drop the triple store's table.
  get_context(self, context)
Return a copy of this store which uses the given 'context' to constrain operations on the stored triples.
  init(self)
Initialise the database by creating a table and a sequence.
  init_sequence(self)
Initialise the BNode sequence.
  init_table(self)
Initialise the triple store's table.
  intersection(self, queries)
  negation(self, result)
  objects(self, subject, predicate, pattern, fn, ordering, limit)
Return objects for the given 'subject' and/or 'predicate' identifiers.
  predicates(self, subject, object, pattern, ordering, limit)
Return predicates for the given 'subject' and/or 'object' identifiers.
  remove(self, pattern)
Remove all triples conforming to the given 'pattern'.
  remove_context(self, context)
Removes the specified 'context' from the database.
  rollback(self)
Roll back (undo) the changes made to the triple store.
  subject(self, subject)
Return a Subject for the given 'subject' identifier.
  subjects(self, predicate, object, pattern, ordering, limit)
Return subjects for the given 'predicate' and/or 'object' identifiers.
  triples(self, pattern, fn, ordering, limit)
Return triples conforming to the given 'pattern'.
  union(self, queries)
  _column(self, name, index)
Return the qualified column name for the given 'name' and optional 'index'.
  _convert(self, value)
Convert a 'value' into a Unicode object and a type code.
  _get_bnode_id(self)
Return a BNode identifier using the database.
  _get_conditions(self, pattern, index)
Return a query conditions list and a values list for the given 'pattern'.
  _instantiate(self, value, type_code)
Instantiate and return an object from the given 'value' and 'type_code'.
  _pmark(self, i)
Return the appropriate parameter marker for the chosen database system.
  _pmarks(self, s)
Encode the given string 's' so that parameter markers are suitable for the chosen database system.
  _present(self, values)
Present the given 'values' collection in the appropriate form for the chosen database system (either as a dictionary mapping parameter names to values, or as the provided collection of values).
  _table(self, index)
Return the aliased table name for the given, optional 'index'.

Class Variable Summary
dict codes_to_names = {'B': 'BNode', 'U': 'URIRef', 'L': 'Lit...
dict names_to_codes = {'Literal': 'L', 'BNode': 'B', 'Namespa...
str null_context = 'None'

Method Details

__init__(self, adapter, context=None, table_name=None, sequence_name=None, debug=0)
(Constructor)

Initialise access to the store via the given 'adapter' and employing the given, optional 'context' URI, using a table with the given, optional 'table_name' ("triples" by default) and a sequence (for BNode generation) with the optional 'sequence_name' ("bnode" by default).

If the optional 'debug' parameter is set to a true value, the SQL statements issued to the database system will be displayed on standard output.

add(self, pattern)

Add a triple using the information found in the given 'pattern'.

close(self)

Close the connection to the database system.

commit(self)

Commit the changes made to the triple store.

contexts(self)

Return a list of contexts found in this store.

count(self, pattern)

Return a count of the triples conforming to the given 'pattern'.

delete(self)

Drop the store's table and sequence.

delete_sequence(self)

Drop the BNode sequence.

delete_table(self)

Drop the triple store's table.

get_context(self, context)

Return a copy of this store which uses the given 'context' to constrain operations on the stored triples.

init(self)

Initialise the database by creating a table and a sequence.

init_sequence(self)

Initialise the BNode sequence.

init_table(self)

Initialise the triple store's table.

objects(self, subject=None, predicate=None, pattern=None, fn=None, ordering=None, limit=None)

Return objects for the given 'subject' and/or 'predicate' identifiers.

Where the given function 'fn' is specified (as a string containing a reference to selected objects as denoted by the "_" character), this function is applied in the underlying query; for example:

"substr(_, 1, 4)"

Where the 'ordering' is specified (as a tuple optionally containing predicates and ending with a ordering "direction" - either "asc" or "desc"), a query is produced which attempts to find objects through the traversal of triples via the predicates and to sort them accordingly; for example:

("pr1", "pr2", "asc")

Where a 'limit' is specified (as an integer), the number of results will be limited to the stated amount.

predicates(self, subject=None, object=None, pattern=None, ordering=None, limit=None)

Return predicates for the given 'subject' and/or 'object' identifiers.

Where the 'ordering' is specified (as a tuple optionally containing predicates and ending with a ordering "direction" - either "asc" or "desc"), a query is produced which attempts to find objects through the traversal of triples via the predicates and to sort them accordingly; for example:

("pr1", "pr2", "asc")

Where a 'limit' is specified (as an integer), the number of results will be limited to the stated amount.

remove(self, pattern)

Remove all triples conforming to the given 'pattern'.

remove_context(self, context)

Removes the specified 'context' from the database.

rollback(self)

Roll back (undo) the changes made to the triple store.

subject(self, subject)

Return a Subject for the given 'subject' identifier.

subjects(self, predicate=None, object=None, pattern=None, ordering=None, limit=None)

Return subjects for the given 'predicate' and/or 'object' identifiers.

Where the 'ordering' is specified (as a tuple optionally containing predicates and ending with a ordering "direction" - either "asc" or "desc"), a query is produced which attempts to find objects through the traversal of triples via the predicates and to sort them accordingly; for example:

("pr1", "pr2", "asc")

Where a 'limit' is specified (as an integer), the number of results will be limited to the stated amount.

triples(self, pattern, fn=None, ordering=None, limit=None)

Return triples conforming to the given 'pattern'.

Where the given function 'fn' is specified (as a string containing a reference to selected objects as denoted by the "_" character), this function is applied in the underlying query; for example:

"substr(_, 1, 4)"

Where the 'ordering' is specified (as a tuple optionally containing predicates and ending with a ordering "direction" - either "asc" or "desc"), a query is produced which attempts to find objects through the traversal of triples via the predicates and to sort them accordingly; for example:

("pr1", "pr2", "asc")

Where a 'limit' is specified (as an integer), the number of results will be limited to the stated amount.

_column(self, name, index=None)

Return the qualified column name for the given 'name' and optional 'index'. If 'index' is not specified (or None), an unqualified name will be returned.

_convert(self, value)

Convert a 'value' into a Unicode object and a type code.

_get_bnode_id(self)

Return a BNode identifier using the database.

_get_conditions(self, pattern, index=None)

Return a query conditions list and a values list for the given 'pattern'. If the optional 'index' flag is specified (and set to a value other than None), the column names will be qualified with an appropriate table name.

_instantiate(self, value, type_code)

Instantiate and return an object from the given 'value' and 'type_code'.

_pmark(self, i)

Return the appropriate parameter marker for the chosen database system.

_pmarks(self, s)

Encode the given string 's' so that parameter markers are suitable for the chosen database system.

_present(self, values)

Present the given 'values' collection in the appropriate form for the chosen database system (either as a dictionary mapping parameter names to values, or as the provided collection of values).

_table(self, index=None)

Return the aliased table name for the given, optional 'index'. If 'index' is not specified (or None), a plain table name will be returned.

Class Variable Details

codes_to_names

Type:
dict
Value:
{'B': 'BNode', 'U': 'URIRef', 'L': 'Literal'}                          

names_to_codes

Type:
dict
Value:
{'Literal': 'L', 'BNode': 'B', 'Namespace': 'U', 'URIRef': 'U'}        

null_context

Type:
str
Value:
'None'                                                                 

Generated by Epydoc 2.1 on Fri Mar 31 17:48:37 2006 http://epydoc.sf.net