MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / ensure_target_empty

Function ensure_target_empty

scripts/migrate_sqlite_to_postgres.py:119–128  ·  view source on GitHub ↗
(connection: Connection, plan: Sequence[TablePlan])

Source from the content-addressed store, hash-verified

117
118
119def ensure_target_empty(connection: Connection, plan: Sequence[TablePlan]) -> None:
120 non_empty: list[str] = []
121 for item in plan:
122 count = connection.execute(select(func.count()).select_from(item.target_table)).scalar_one()
123 if count:
124 non_empty.append(f"{item.name}={count}")
125 if non_empty:
126 raise MigrationError(
127 "目标库不是空库。请加上 --truncate-target 后重试。非空表: " + ", ".join(non_empty[:8])
128 )
129
130
131def fetch_source_rows(connection: Connection, plan: TablePlan) -> list[dict]:

Callers 1

Calls 2

MigrationErrorClass · 0.85
countMethod · 0.80

Tested by

no test coverage detected