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

Method validate_database_url

src/config/settings.py:785–797  ·  view source on GitHub ↗
(cls, v)

Source from the content-addressed store, hash-verified

783 @field_validator('database_url', mode='before')
784 @classmethod
785 def validate_database_url(cls, v):
786 if isinstance(v, str):
787 if v.startswith(("postgres://", "postgresql://")):
788 return _normalize_database_url(v)
789 if v.startswith(("postgresql+psycopg://", "postgresql+psycopg2://")):
790 return v
791 if isinstance(v, str) and v.startswith("sqlite:///"):
792 return v
793 if isinstance(v, str) and not v.startswith(("sqlite:///", "postgresql://", "postgresql+psycopg://", "postgresql+psycopg2://", "mysql://")):
794 # 如果是文件路径,转换为 SQLite URL
795 if os.path.isabs(v) or ":/" not in v:
796 return f"sqlite:///{v}"
797 return v
798
799 # Web UI 配置
800 webui_host: str = "0.0.0.0"

Callers

nothing calls this directly

Calls 1

_normalize_database_urlFunction · 0.85

Tested by

no test coverage detected