✨ feat(sync): add data consistency compare (count + ID-set)
This commit is contained in:
@@ -143,6 +143,18 @@ class SqlWriter:
|
||||
)
|
||||
return cur.fetchone() is not None
|
||||
|
||||
def count_target(self, schema: str, table: str) -> int:
|
||||
"""Return ``COUNT(*)`` for ``[schema].[table]`` (compare count check)."""
|
||||
cur = self._conn.cursor()
|
||||
cur.execute(f"SELECT COUNT(*) FROM [{schema}].[{table}]")
|
||||
return cur.fetchone()[0]
|
||||
|
||||
def read_target_ids(self, schema: str, table: str) -> list:
|
||||
"""Return every ``ID`` from ``[schema].[table]``, ascending (compare IDs)."""
|
||||
cur = self._conn.cursor()
|
||||
cur.execute(f"SELECT ID FROM [{schema}].[{table}] ORDER BY ID")
|
||||
return [r[0] for r in cur.fetchall()]
|
||||
|
||||
def _has_identity(self, schema: str, table: str) -> bool:
|
||||
"""True if ``[schema].[table]`` has an IDENTITY column (the ``ID`` PK)."""
|
||||
cur = self._conn.cursor()
|
||||
|
||||
Reference in New Issue
Block a user