Spaces:
Runtime error
Runtime error
Download scripts/init_db.py from BattleFiven/ai-tester-platform: direct link, hf CLI and curl.
- Browser
- Download file 809 Bytes
-
https://huggingface.co/spaces/BattleFiven/ai-tester-platform/resolve/main/scripts/init_db.py
- Command line
-
hf download hf://spaces/BattleFiven/ai-tester-platform/scripts/init_db.py
-
curl -L -o init_db.py https://huggingface.co/spaces/BattleFiven/ai-tester-platform/resolve/main/scripts/init_db.py
809 Bytes
| """Initialize database tables for the configured DATABASE_URL.""" | |
| import os | |
| from pathlib import Path | |
| from dotenv import load_dotenv | |
| def _mask_db_url(url: str) -> str: | |
| if not url: | |
| return "(not set)" | |
| if "@" not in url: | |
| return url | |
| scheme, rest = url.split("//", 1) | |
| creds, host = rest.split("@", 1) | |
| if ":" in creds: | |
| user, _ = creds.split(":", 1) | |
| creds = f"{user}:****" | |
| return f"{scheme}//{creds}@{host}" | |
| def main() -> None: | |
| env_path = Path(__file__).resolve().parents[1] / ".env" | |
| load_dotenv(env_path) | |
| db_url = os.getenv("DATABASE_URL", "") | |
| print(f"Initializing database at: {_mask_db_url(db_url)}") | |
| from src.db import init_db | |
| init_db() | |
| print("Database initialization complete.") | |
| if __name__ == "__main__": | |
| main() | |