architxt.database.export.sql#

Functions

add_foreign_keys_to_table(database_schema, ...)

Add foreign key constraints to the database schema.

create_schema(conn, schema, pk_factory)

Create the schema for the relational database.

create_table_for_group(group, metadata, ...)

Create a table for the given group.

create_table_for_relation(database_schema, ...)

Create a table for the given relation.

default_pk_factory(table_name)

Generate the ID column for the given table.

export_data(data, conn)

Export the data to the relational database.

export_group(group, data, pk_factory)

Export the group to the relational database.

export_relation(tree, data, schema, pk_factory)

Export the relation to the relational database.

export_sql(forest, conn, *[, pk_factory])

Export the forest to the relational database.

export_table_to_insert(table_to_insert, conn)

Export the table to the graph.

export_tree(tree, conn, schema, pk_factory)

Export the tree to the relational database.

get_data_from_group(group)

Get data from the relational database.

architxt.database.export.sql.add_foreign_keys_to_table(database_schema, relation, pk_factory)[source]#

Add foreign key constraints to the database schema.

Parameters:
  • database_schema (dict[str, Table]) – The dictionary of tables in the database schema.

  • relation (Relation) – The relation to build as a foreign key.

  • pk_factory (Callable[str, str]) – A column name factory for the groups primary keys.

Return type:

None

architxt.database.export.sql.create_schema(conn, schema, pk_factory)[source]#

Create the schema for the relational database.

Parameters:
  • conn (Connection) – Connection to the graph.

  • schema (Schema) – The schema to build.

  • pk_factory (Callable[str, str]) – A column name factory for the groups primary keys.

Return type:

Schema

architxt.database.export.sql.create_table_for_group(group, metadata, pk_factory)[source]#

Create a table for the given group.

Parameters:
  • group (Group) – The group to create a table for.

  • metadata (MetaData) – SQLAlchemy metadata to attach the table to.

  • pk_factory (Callable[str, str]) – A column name factory for the groups primary keys.

Return type:

Table

Returns:

SQLAlchemy Table object.

architxt.database.export.sql.create_table_for_relation(database_schema, relation, metadata, pk_factory)[source]#

Create a table for the given relation.

Parameters:
  • database_schema (dict[str, Table]) – The dictionary of tables in the database schema.

  • relation (Relation) – The relation to build the table for.

  • metadata (MetaData) – SQLAlchemy metadata to attach the table to.

  • pk_factory (Callable[str, str]) – A column name factory for the groups primary keys.

Return type:

None

architxt.database.export.sql.default_pk_factory(table_name)[source]#

Generate the ID column for the given table.

Parameters:

table_name (str) – The table name to generate ID for.

Return type:

str

Returns:

The name of the ID column for the table.

architxt.database.export.sql.export_data(data, conn)[source]#

Export the data to the relational database.

Parameters:
  • data (dict) – Data to export.

  • conn (Connection) – Connection to the relational database.

Return type:

None

Returns:

architxt.database.export.sql.export_group(group, data, pk_factory)[source]#

Export the group to the relational database.

Parameters:
  • group (Tree) – Group to export.

  • data (dict[str, dict[str, Any]]) – Data to export.

  • pk_factory (Callable[str, str]) – A column name factory for the groups primary keys.

Return type:

None

architxt.database.export.sql.export_relation(tree, data, schema, pk_factory)[source]#

Export the relation to the relational database.

Parameters:
  • tree (Tree) – Relation to export.

  • data (dict[str, dict[str, Any]]) – Data to export.

  • schema (Schema) – The schema.

  • pk_factory (Callable[str, str]) – A column name factory for the groups primary keys.

Return type:

None

architxt.database.export.sql.export_sql(forest, conn, *, pk_factory=default_pk_factory)[source]#

Export the forest to the relational database.

Parameters:
  • conn (Connection) – Connection to the relational database.

  • forest (Collection[Tree]) – Forest to export.

  • pk_factory (Callable[str, str]) – A column name factory for the groups primary keys.

Return type:

None

architxt.database.export.sql.export_table_to_insert(table_to_insert, conn)[source]#

Export the table to the graph.

Parameters:
Return type:

None

architxt.database.export.sql.export_tree(tree, conn, schema, pk_factory)[source]#

Export the tree to the relational database.

Parameters:
  • tree (Tree) – Tree to export.

  • conn (Connection) – Connection to the relational database.

  • schema (Schema) – The schema.

  • pk_factory (Callable[str, str]) – A column name factory for the groups primary keys.

Return type:

None

architxt.database.export.sql.get_data_from_group(group)[source]#

Get data from the relational database.

Parameters:

group (Tree) – Group to get data from.

Return type:

dict[str, str]

Returns:

Data from the group.