compare_schemas

sqlcompyre.compare_schemas(engine: Engine, left: str, right: str, include_views: bool = False, float_precision: float = 2.220446049250313e-16, collation: str | None = None, ignore_casing: bool = False) SchemaComparison[source]

Compare all tables from two schemas in the database. For multi-part schemas (e.g. for MSSQL), it is possible to only specify the first part of the schema and compare tables from all schemas. In MSSQL, this allows comparing entire databases.

Currently, the comparison only compares tables with the same name (and the same schema for multi-part schema comparisons).

Args:

engine: The engine to use to access the database. left: The name of the “left” schema from which to use tables. For multi-part schemas,

the schema may be specified as <database>.* which then references all schemas (and tables) in <database>. Note that this notation is merely a convention and general regex/glob notation is not supported.

right: The name of the “right” schema whose tables to compare to those of the “left”

one. The naming convention follows the convention for the “left” schema.

include_views: Whether to include views in the comparison. float_precision: The precision of floating point comparisons. Values with an absolute

difference below the precision are considered equal.

collation: An optional collation that is used to compare strings. Useful for making

case-sensitive comparisons even if a table’s column uses a case-insensitive collation.

ignore_casing: Whether casing (e.g. capitalization) should be ignored when matching

table names. This is valuable if only interacting with the database through case-insensitive tools (e.g. SQL).

Returns:

A schema comparison object.