tabulardelta.comparators.sqlmetadata_comparator module

class tabulardelta.comparators.sqlmetadata_comparator.SqlMetadataComparator(engine: ~sqlalchemy.engine.base.Engine, cache_db_metadata: bool = False, _cache: dict[~tabulardelta.comparators.sqlmetadata_comparator._TableDescr, ~tabulardelta.comparators.sqlmetadata_comparator._TableMetadata] = <factory>)[source]

Bases: object

Implements Comparator protocol for comparing SQL Tables.

This will only use metadata from the database, to be as fast as possible.

Methods

compare(self, old: sa.Table | str, new: sa.Table | str) -> TabularDelta:

Compare two SQL tables

cache_db_metadata: bool = False

Whether to cache metadata for whole database to speed up comparisons.

compare(old: Table | str, new: Table | str) TabularDelta[source]

Compare two SQL tables.

Arguments:
old sa.Table | str:

The old table (first table to compare).

new sa.Table | str:

The new table (second table to compare).

Returns TabularDelta:

Metadata and results of the comparison.

dialects = {'mssql': <function get_mssql_metadata>}

Dictionary of supported dialects and their metadata retrieval functions.

engine: Engine

SQLAlchemy engine to connect to the database.

tabulardelta.comparators.sqlmetadata_comparator.get_mssql_metadata(db_name: str | None) tuple[Select, Select][source]

Implementation for retrieving metadata from a Microsoft SQL Server database.

Arguments:
db_name str | None:

Name of the database to retrieve metadata from.

Returns tuple[RowSelect, ColumnSelect]:

SQL queries to retrieve row count and column information.