کنترل مهاجرت: شمارش مبدأ در برابر مقصد
حجم جدولبهجدول سیستم قدیم و جدید رو مقایسه میکنه، دلتاهای علامتدار رو نشون میده و برای سوییچ حکم GO / NO-GO صادر میکنه.
کاربرد
چکلیست سوییچ توی یکشنبهی مهاجرت: مدرک عددی که چیزی توی راه گم نشده.
پیشنیازها
Python 3.9+ (bibliothèque standard)
Python
import sqlite3
src = sqlite3.connect("ancien_si.db")
dst = sqlite3.connect("nouveau_si.db")
TABLES = ["clients", "commandes", "lignes_commande", "factures", "avoirs"]
print(f"{'table':<18} {'source':>9} {'cible':>9} {'delta':>7} verdict")
print("-" * 56)
echecs = 0
for t in TABLES:
n_src = src.execute(f"SELECT COUNT(*) FROM {t}").fetchone()[0]
n_dst = dst.execute(f"SELECT COUNT(*) FROM {t}").fetchone()[0]
ok = n_src == n_dst
echecs += not ok
print(f"{t:<18} {n_src:>9} {n_dst:>9} {n_dst - n_src:>+7} {'OK' if ok else 'KO'}")
print("-" * 56)
print("GO pour la bascule" if echecs == 0
else f"NO-GO : {echecs} table(s) en écart — investiguer avant 6 h")نتیجه
table source cible delta verdict -------------------------------------------------------- clients 18442 18442 +0 OK commandes 204318 204318 +0 OK lignes_commande 612954 612951 -3 KO factures 88107 88107 +0 OK avoirs 2231 2231 +0 OK -------------------------------------------------------- NO-GO : 1 table(s) en écart — investiguer avant 6 h
MigrationSQLiteContrôleGO/NO-GO