architxt.database.loader.cypher#

Functions

build_group(node)

Create a tree representation for a table with its columns and data.

build_relation(node1, node2, rel_name)

Create a tree representation for a relation.

get_relation_with_data(session)

Get the relations with data from the graph.

get_root_nodes(session, sample)

Get the root nodes of the graph.

parse_relation(record, visited_relations, ...)

Parse a relation between two nodes.

read_cypher(session, *[, sample])

Read the graph instance as a tree using Neo4j.

read_node(node, *, session, ...)

Read the node and its children from the graph.

architxt.database.loader.cypher.build_group(node)[source]#

Create a tree representation for a table with its columns and data.

Parameters:

node (Union[Node, Relationship]) – Node representing the table.

Return type:

Tree

Returns:

A tree representing the table’s structure and data.

architxt.database.loader.cypher.build_relation(node1, node2, rel_name)[source]#

Create a tree representation for a relation.

Parameters:
  • node1 (Node) – The first node in the relation.

  • node2 (Node) – The second node in the relation.

  • rel_name (str) – The name of the relation.

Return type:

Tree

Returns:

A tree representing the relation between the two nodes.

architxt.database.loader.cypher.get_relation_with_data(session)[source]#

Get the relations with data from the graph.

Parameters:

session (Session) – Neo4j session.

Return type:

set[str]

Returns:

A set of relations with data.

architxt.database.loader.cypher.get_root_nodes(session, sample)[source]#

Get the root nodes of the graph.

Parameters:
  • session (Session) – Neo4j session.

  • sample (int) – Number of samples to get.

Return type:

Generator[Node, None, None]

Returns:

A generator of root nodes.

architxt.database.loader.cypher.parse_relation(record, visited_relations, relations_with_data, *, session)[source]#

Parse a relation between two nodes.

Parameters:
  • record (Record) – Record containing the relation.

  • visited_relations (set[str]) – Set of visited relations.

  • relations_with_data (set[str]) – Set of relations with data.

  • session (Session) – Neo4j session.

Return type:

Generator[Tree, None, None]

Returns:

A generator that yields trees representing the relation.

architxt.database.loader.cypher.read_cypher(session, *, sample=0)[source]#

Read the graph instance as a tree using Neo4j.

Parameters:
  • session (Session) – Neo4j session.

  • sample (int) – Number of samples for each node to get.

Return type:

Generator[Tree, None, None]

Returns:

A generator that yields trees representing the graph.

architxt.database.loader.cypher.read_node(node, *, session, visited_relations, relations_with_data)[source]#

Read the node and its children from the graph.

Parameters:
  • node (Node) – Node to read.

  • session (Session) – Neo4j session.

  • visited_relations (set[str]) – Set of visited relations.

  • relations_with_data (set[str]) – Set of relations with data.

Return type:

Generator[Tree, None, None]

Returns:

A generator that yields trees representing the node.