Transaction object¶
-
class
Transaction
(connection, node_factory)¶ Representation of a database transaction and entrypoint for global tree operations.
Parameters: - connection (Connection) – Postgres connection object. Its
autocommit
attribute will be set toFalse
. - node_factory (object) – Factory class for creating node objects
-
clear
()¶ Empty database tables.
-
get_node
(node_id)¶ Get node with given database ID.
Parameters: node_id (int) – Database ID
-
get_nodes_by_property_dict
(query)¶ Get a set of nodes which have all key/value pairs of
query
in their properties. Inherited properties are not considered.Parameters: query (dict) – The dictionary to search for
-
get_nodes_by_property_key
(key)¶ Get a set of nodes which have a property named
key
in their properties. Inherited properties are not considered.Parameters: key (str) – The key to search for
-
get_nodes_by_property_value
(key, value)¶ Get a set of nodes which have a property
key
with valuevalue
. Inherited properties are not considered.Parameters: - key (str) – The key to search for
- value (object) – The exact value to sarch for
-
get_root_node
()¶ Get root node if exists, other
None
.
-
get_tree_size
()¶ Get amount of nodes inside the tree.
-
insert_root_node
(properties=None)¶ Create root node, then get it.
Parameters: properties (dict) – Inheritable key/value pairs (see Property functions)
-
install
()¶ Create tables and trigger functions in database.
-
is_compatible_postgres_version
()¶ Determine whether PostgreSQL server version is compatible with libtree.
-
print_tree
()¶ Simple function to print tree structure to stdout.
-
rollback
()¶ Discard changes. See rollback() .
-
uninstall
()¶ Remove libtree tables from database.
- connection (Connection) – Postgres connection object. Its