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

Function normalize_postgres_url

scripts/migrate_sqlite_to_postgres.py:55–65  ·  view source on GitHub ↗
(value: str)

Source from the content-addressed store, hash-verified

53
54
55def normalize_postgres_url(value: str) -> str:
56 raw = str(value or "").strip()
57 if not raw:
58 raise MigrationError("PostgreSQL 目标库 URL 不能为空")
59 if raw.startswith("postgres://"):
60 raw = "postgresql://" + raw[len("postgres://"):]
61 if get_database_backend(raw) != "postgresql":
62 raise MigrationError("目标库必须是 PostgreSQL 连接字符串")
63 if raw.startswith("postgresql://"):
64 return "postgresql+psycopg://" + raw[len("postgresql://"):]
65 return raw
66
67
68def chunked_rows(rows: Sequence[dict], chunk_size: int) -> Iterator[list[dict]]:

Callers 1

Calls 2

get_database_backendFunction · 0.90
MigrationErrorClass · 0.85

Tested by

no test coverage detected