sqlcompyre.analysis.table_comparison module

class sqlcompyre.analysis.table_comparison.TableComparison(engine: Engine, left_table: FromClause, right_table: FromClause, join_columns: list[str] | None, column_name_mapping: dict[str, str] | None, ignore_columns: list[str] | None, float_precision: float, collation: str | None, ignore_casing: bool, infer_primary_keys: bool)[source]

Bases: object

Compare the content of two SQL database tables.

Note:

This class should never be initialized directly. Use the compare_tables() function instead.

Attributes:
column_matches

A comparison between the column values of the two tables.

column_names

A comparison between the column names of the two tables.

equal

Whether the compared tables are equal.

join_columns

The columns used for joining the two tables.

row_counts

A comparison between the number of rows in each table.

row_matches

A comparison between the contents of the individual rows in the two tables.

Methods

get_top_changes(column_name[, n])

Gets the most common changes in a single column.

summary_report()

Generate a report that summarizes the table comparison.

property column_matches: ColumnMatches

A comparison between the column values of the two tables.

property column_names: Names

A comparison between the column names of the two tables.

property equal: bool

Whether the compared tables are equal.

get_top_changes(column_name: str, n: int = 5) dict[str, int][source]

Gets the most common changes in a single column.

Args:

column_name: The name of the column in the “left” table. n: The number of changes to get.

Returns:

A dictionary where the key is a change in string form (maybe “true -> false”) and the value is the number of times the change occurs.

property join_columns: list[str]

The columns used for joining the two tables.

property row_counts: Counts

A comparison between the number of rows in each table.

property row_matches: RowMatches

A comparison between the contents of the individual rows in the two tables.

summary_report() Report[source]

Generate a report that summarizes the table comparison.

Returns:

A report summarizing the comparison of the two tables.