architxt.database.loader.sql#
Functions
|
Create a tree representation for a table with its columns and data. |
|
Handle the current data for a table and its referred table. |
|
Retrieve tables that are part of a cycle in the database relations. |
|
Retrieve the root tables in the database by identifying tables that are not referenced as foreign keys. |
|
Check if a table is a many-to-many association table. |
|
Parse a row of an association table into trees. |
|
Parse a row of a table into trees. |
|
Read the database instance as a tree. |
|
Process the relations of a given table, retrieve data, and construct tree representations. |
|
Process the relations of a table that is not referenced by any other tables. |
- architxt.database.loader.sql.build_group(table, row)[source]#
Create a tree representation for a table with its columns and data.
- Parameters:
table (
Table
) – The table to process.row (
Row
) – A row of the table.
- Return type:
- Returns:
A tree representing the table’s structure and data.
- architxt.database.loader.sql.build_relation(left_table, right_table, left_row, right_row, node_data=None, name='')[source]#
Handle the current data for a table and its referred table.
- Parameters:
left_table (
Table
) – The left table of the relation.right_table (
Table
) – The right table of the relation.left_row (
Row
) – The left table row of the relation.right_row (
Row
) – The right table row of the relation.node_data (
Optional
[dict
[str
,Any
]]) – Dictionary containing relation data.name (
str
) – Name of the relation, if not set, it will be automatically generated.
- Return type:
- Returns:
The tree of the relation.
- architxt.database.loader.sql.get_cycle_tables(tables)[source]#
Retrieve tables that are part of a cycle in the database relations.
If multiple tables are in a cycle, only the one with the maximum foreign keys is returned.
- architxt.database.loader.sql.get_root_tables(tables)[source]#
Retrieve the root tables in the database by identifying tables that are not referenced as foreign keys.
- architxt.database.loader.sql.is_association_table(table)[source]#
Check if a table is a many-to-many association table.
- Parameters:
table (
Table
) – The table to check.- Return type:
- Returns:
True if the tale is a relation else False.
- architxt.database.loader.sql.parse_association_table(table, row, *, conn)[source]#
Parse a row of an association table into trees.
The table is discarded and represented only as a relation between the two linked tables.
- architxt.database.loader.sql.parse_table(table, row, *, conn, _visited_links=None)[source]#
Parse a row of a table into trees.
- Parameters:
table (
Table
) – The table to process.row (
Row
) – A row of the table.conn (
Connection
) – SQLAlchemy connection._visited_links (
Optional
[set
[ForeignKey
]]) – Set of visited relations to avoid cycles.
- Yield:
Trees representing the relations and data for the table.
- Return type:
- architxt.database.loader.sql.read_database(conn, *, simplify_association=True, search_all_instances=False, sample=0)[source]#
Read the database instance as a tree.
- Parameters:
- Return type:
- Returns:
A list of trees representing the database.
- architxt.database.loader.sql.read_table(table, *, conn, simplify_association=False, sample=0)[source]#
Process the relations of a given table, retrieve data, and construct tree representations.
- Parameters:
- Return type:
- Returns:
A list of trees representing the relations and data for the table.