Spaces:
Runtime error

BattleFiven's picture
deploy: round 6 save_intermediate light (sha 05316bb)
ed86a97
Raw History Blame Contribute Delete
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()