provdbconnector.db_adapters package

Submodules

provdbconnector.db_adapters.baseadapter module

class provdbconnector.db_adapters.baseadapter.DbDocument(document, bundles)

Bases: tuple

bundles

Alias for field number 1

document

Alias for field number 0

class provdbconnector.db_adapters.baseadapter.DbBundle(records, bundle_record)

Bases: tuple

bundle_record

Alias for field number 1

records

Alias for field number 0

class provdbconnector.db_adapters.baseadapter.DbRecord(attributes, metadata)

Bases: tuple

attributes

Alias for field number 0

metadata

Alias for field number 1

class provdbconnector.db_adapters.baseadapter.DbRelation(attributes, metadata)

Bases: tuple

attributes

Alias for field number 0

metadata

Alias for field number 1

class provdbconnector.db_adapters.baseadapter.BaseAdapter(*args, **kwargs)[source]

Bases: object

Interface class for a prov database adapter

connect(authentication_info)[source]

Establish the database connection / login into the database

Parameters:authentication_info (dict) – a custom dict with credentials
Returns:Indicate whether the connection was successful
Return type:boolean
Raises:InvalidOptionsException
save_element(attributes, metadata)[source]

Saves a entity, activity or entity into the database

Parameters:
  • attributes (dict) – Attributes as dict for the record. Be careful you have to encode the dict
  • metadata (dict) – Metadata as dict for the record. Be careful you have to encode the dict but you can be sure that all meta keys are always there
Returns:

Record id

Return type:

str

save_relation(from_node, to_node, attributes, metadata)[source]

Create a relation between 2 nodes

Parameters:
  • from_node (str) – The identifier
  • to_node – The identifier for the destination node
  • attributes (dict) – Attributes as dict for the record. Be careful you have to encode the dict
  • metadata (dict) – Metadata as dict for the record. Be careful you have to encode the dict but you can be sure that all meta keys are always there
Type:

to_node: str

Returns:

Record id

Return type:

str

get_records_by_filter(attributes_dict=None, metadata_dict=None)[source]

Returns all records (nodes and relations) based on a filter dict. The filter dict’s are and AND combination but only the start node must fulfill the conditions. The result should contain all associated relations and nodes together

Parameters:
  • attributes_dict (dict) –
  • metadata_dict (dict) –
Returns:

list of relations and nodes

Return type:

list

get_records_tail(attributes_dict=None, metadata_dict=None, depth=None)[source]

Returns all connected nodes and relations based on a filter. The filter is an AND combination and this describes the filter only for the origin nodes.

Parameters:
  • attributes_dict (dict) –
  • metadata_dict (dict) –
  • depth (int) –
Returns:

a list of relations and nodes

Return type:

list

get_bundle_records(bundle_identifier)[source]

Returns the relations and nodes for a specific bundle identifier. Please use the bundle association to get all bundle nodes. Only the relations belongs to the bundle where the start AND end node belong also to the bundle. Except the prov:Mention see: W3C bundle links

Parameters:bundle_identifier (str) – The bundle identifier
Returns:list of nodes and bundles
Return type:list
get_record(record_id)[source]

Return a single record

Parameters:record_id (str) – The id
Returns:DbRecord
Return type:DbRecord
get_relation(relation_id)[source]

Returns a single relation

Parameters:relation_id (str) – The id
Returns:DbRelation
Return type:DbRelation
delete_records_by_filter(attributes_dict, metadata_dict)[source]

Delete records by filter

Parameters:
  • attributes_dict (dict) –
  • metadata_dict (dict) –
Returns:

Indicates whether the deletion was successful

Return type:

boolean

Raises:

NotFoundException

delete_record(record_id)[source]

Delete a single record

Parameters:record_id (str) –
Returns:Indicates whether the deletion was successful
Return type:boolean
Raises:NotFoundException
delete_relation(relation_id)[source]

Delete a single relation

Parameters:relation_id (str) –
Returns:Indicates whether the deletion was successful
Return type:boolean
Raises:NotFoundException

Module contents